2.0.7版本中打开增强模式无法启动项目,关闭增强模式就正常。
2.0.7版本中打开增强模式无法启动项目,关闭增强模式就正常。
配置为:
@EnableSwagger2 @EnableKnife4j @Configuration public class Knife4jConfiguration { @Bean(value = "defaultApi2") public Docket defaultApi2() { Docket docket=new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) //分组名称 .groupName("测试分组") .select() //这里指定Controller扫描包路径 .apis(RequestHandlerSelectors.basePackage("com.xiaominfo.knife4j.controller")) .paths(PathSelectors.any()) .build(); return docket; } private ApiInfo apiInfo(){ return new ApiInfoBuilder() .title("swagger-bootstrap-ui很棒~~~!!!") .description("swagger-bootstrap-ui-demo RESTful APIs") .termsOfServiceUrl("http://www.group.com/") .contact("group@qq.com") .version("1.0") .build(); } }
application.yml
knife4j: enable: true documents: - group: 1.2.x name: 测试自定义标题分组 # 某一个文件夹下所有的.md文件 locations: classpath:checkList/*
[2021-03-25 11:35:23] org.springframework.boot.SpringApplication [821] [anonymous] [] - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dynamicResponseModelReader': Resolution of declared constructors on bean Class [com.github.xiaoymin.knife4j.spring.plugin.DynamicResponseModelReader] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2] failed; nested exception is java.lang.NoClassDefFoundError: springfox/documentation/spi/schema/EnumTypeDeterminer
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:284)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1269)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1184)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你springfox版本冲突,knife4j 2.0.7版本底层依赖的springfox是2.10.5,你配置中的注解`@EnableSwagger2`还是springfox 2.9.2的,你可以去除低版本的springfox依赖
参考版本说明文档:https://xiaoym.gitee.io/knife4j/documentation/changelog.html