拦截器
@Slf4j
@Component
public class LcOpPermissionInterceptor extends HandlerInterceptorAdapter {
......
}
将拦截器注入适配器中
@Configuration
public class LcOpWebMvcConfigurer extends WebMvcConfigurerAdapter {
@Autowired
private LcOpPermissionInterceptor lcOpPermissionInterceptor;
这样写有的时候会导致循环依赖问题,需要换一种写法。去掉上面的
@Component
注解,改用下面@Bean
来注入Bean
@Configuration
public class LcOpWebMvcConfigurer extends WebMvcConfigurerAdapter {
@Bean
public LcOpPermissionInterceptor lcOpPermissionInterceptor(){
return new LcOpPermissionInterceptor() ;
}
原文地址:https://www.cnblogs.com/zhangjianbing/p/11424446.html
时间: 2024-11-02 07:47:51