栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

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

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/424482.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号