本文介绍了Spring Security的注解元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能建立的Spring Security的Meta Annotatations @ preAuthorize @Component @Qualifier

Is it possible to build Meta Annotatations of Spring Security @PreAuthorize like for @Component or @Qualifier?

我想要做的就是替换 @ preAuthorize(hasRole(管理员))通过像一个快捷键 @IsAdmin 。但我没有找到文档中的任何暗示。

What I want to do is replace @PreAuthorize("hasRole('ADMIN')") by a shortcut like @IsAdmin. But I did not find any hint in the documentation.

推荐答案

此工作至少在春季安全3.0.2.RELEASE:

This works at least with Spring Security 3.0.2.RELEASE:

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@PreAuthorize("hasRole('ADMIN')")
public @interface IsAdmin
{
}

这篇关于Spring Security的注解元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 04:39