shiro整合swagger2出现的循环依赖问题:defaultWebSecurityManager ,SpringfoxWebMvcConfiguration

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
@EnableSwagger2
@EnableWebMvc

@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注解作用

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值