上图是我自实现的注解,并且对注解的 value 参数添加了 idea 提供的 @Language(“SpEL”) 注解,所以它能识别到是spel 表达式。但是参数 #loginUser 以及 #opt 却无法识别到。
这个是SpringSecurity 提供的 注解,它能识别到spel 表达式,同时还能识别到方法参数,通过鼠标还能点击跳转。
如何才能做到像SpringSecurity 那样,让idea 识别到spel 表达式中的参数,并且点击能跳转到参数具体的位置。
上图是我自实现的注解,并且对注解的 value 参数添加了 idea 提供的 @Language(“SpEL”) 注解,所以它能识别到是spel 表达式。但是参数 #loginUser 以及 #opt 却无法识别到。
如何才能做到像SpringSecurity 那样,让idea 识别到spel 表达式中的参数,并且点击能跳转到参数具体的位置。
method.parameters设置为true,feilds.roo设置对应参数
{
"com.example.demo.ext.Auth@curr": {
"prefix": "",
"suffix": "",
"method": {
"result": false,
"resultName": "result",
"parameters": true,
"parametersPrefix": [
"p",
"a"
]
},
"fields": {
"root": "com.example.demo.domain.User"
}
}
}
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Auth {
String curr();
}
@RestController
public class TestController {
@Auth(curr = "#user.username")
public String test(@RequestBody User user) {
return "ok";
}
}
支持提示和跳转