You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.3 KiB
1.3 KiB
解析框架笔记
@Primary注解是Spring框架中的一个注解,用于标识一个Bean作为默认的实现类
在Spring Boot 3.* 中,想要实行拦截器注入,可以使用以下方法来实现:
@Configuration
public class SpringBootMvConfig implements SpringBootMvServer {
@Bean
public InterceptorRegistry interceptorRegistry() {
return new InterceptorRegistry();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new SaInterceptor(handler->{
SaRouter.match(
"/api/**").check(r-> StpUtil.checkLogin());
SaRouter.match("/admin/**").check(r-> StpUtil.checkRole("admin"));
}))
.addPathPatterns("/**")
.excludePathPatterns("/acc/login", "/acc/isLogin", "/acc/logout");
}
@Bean
public StpLogic getStpLogicJwt() {
return new StpLogicJwtForSimple();
}
}
这样就可以在Spring Boot 3.* 中实现了。
并且想要注册多个可以采用数组方式管理并统一注入。
下面是运行的结果:

