shiro整合swagger2出现的循环依赖问题:
*************************** APPLICATION FAILED TO START *************************** Description: The dependencies of some of the beans in the application context form a cycle: objectMapperConfigurer defined in class path resource [springfox/documentation/spring/web/SpringfoxWebMvcConfiguration.class] ↓ authorizationAttributeSourceAdvisor defined in class path resource [com/wdf/test/shiro/config/ShiroManager.class] ┌─────┐ | defaultWebSecurityManager defined in class path resource [com/wdf/test/shiro/config/ShiroConfig.class] ↑ ↓ | shiroFilterFactoryBean defined in class path resource [com/wdf/test/shiro/config/ShiroConfig.class] └─────┘ |
解决方案,
在@EnableSwagger2 下加上@EnableWebMvc注解解决。
最后在swagger的配置文件类上加了第三个注解:@EnableWebMvc。
@Configuration |
@EnableWebMvc 的作用
引入了这样一个类DelegatingWebMvcConfiguration
DelegatingWebMvcConfiguration类会把所有实现了接口WebMvcConfigurer的类包括自己定义的类托管到spring容器的自定义的配置类(因为也实现了它)都会把这些配置加上。
DelegatingWebMvcConfiguration这个类上加了一个注解@Configuration(proxyBeanMethods = false),
proxyBeanMethods = true 或不写,是Full模式,
proxyBeanMethods = false 是lite模式。
lite模式保证调用相同类的@Bean方法而保证是容器内的Bean,这有效规避了在“Lite模式”下操作时的错误。
参考:
使用springfox+swagger2书写API文档__好好学习的博客-CSDN博客_springfox
(18条消息) spring mvc之注解@EnableWebMvc_程序猿的樊笼-CSDN博客_enablewebmvc注解作用