是否可以为 @Component
或 @Qualifier
构建 Spring Security @PreAuthorize
的元注释?
我想要做的是用 @IsAdmin
之类的快捷方式替换 @PreAuthorize("hasRole('ADMIN')")
。但是我在文档中没有找到任何提示。
最佳答案
这至少适用于 Spring Security 3.0.2.RELEASE:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@PreAuthorize("hasRole('ADMIN')")
public @interface IsAdmin
{
}
关于java - Spring Security 元注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5402723/