java - Spring Boot 自定义注解
问题描述
在我所有的项目中,我都需要相同的 WebSecurityConfig。所以我复制了扩展 WebSecurityConfigurerAdapter 的相同实现。
我喜欢将它添加到我在每个项目中使用的公共库中,并为此创建一个注释。但是注解类不能有超类。
我试过这个:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Configuration
@EnableWebSecurity
public @interface EnableGlobalSecurity extends WebSecurityConfigurerAdapter {
}
有没有更好的方法让这个工作?我只想通过添加注释或类似的东西来添加我的 SecurityConfiguration。
解决方案
推荐阅读
- mysql - 如何检查一列是否有两个以上的项目,以及它是否比 SQL 中的 avg() 多?
- themes - 如何更改 RStudio 终端中光标的颜色?
- php - 使用 PHP 的 API PUT 请求
- c++ - 本地对象超出范围后异步成员函数会发生什么?
- flutter - 流生成器不接收数据(无限连接状态 = 等待)颤振
- flask - 有没有办法为模板中的 Flask WTForms 错误简化此代码
- python - python3中key=len, key=lambda x: (len(x), x)) 有什么区别
- python-sphinx - 仅在页面右侧三分之一处带有 Sphinx 和 RinohType 的代码文档
- c++ - 无法从项目目录打开 .txt 文件
- sql - 反透视取自另一个表的列