更新目录接口运行报错

更新目录接口运行报错

在新增了目录时,swagger正常使用。而 增加了“更新目录以后”,启动mallApplication却不行了。

[08:23 22:51:50.276] [ERROR] [org.springframework.boot.SpringApplication] - Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceModelToSwagger2MapperImpl': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.swagger2.mappers.ServiceModelToSwagger2MapperImpl] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:287) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1286) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1201) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]

at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]

at com.imooc.mall.MallApplication.main(MallApplication.java:13) [classes/:?]

Caused by: java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.swagger2.mappers.ServiceModelToSwagger2MapperImpl] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]

at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:477) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:318) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:265) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

... 18 more

Caused by: java.lang.NoClassDefFoundError: io/swagger/models/Contact

at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:1.8.0_191]

at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[?:1.8.0_191]

at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[?:1.8.0_191]

at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:459) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:318) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:265) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

... 18 more

Caused by: java.lang.ClassNotFoundException: io.swagger.models.Contact

at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_191]

at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_191]

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[?:1.8.0_191]

at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_191]

at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:1.8.0_191]

at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[?:1.8.0_191]

at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[?:1.8.0_191]

at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:459) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:318) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:265) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]

... 18 more


Process finished with exit code 1


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕阿园 2021-08-24 13:16:04

同学你好,可能是由于版本问题导致的冲突,同学使用的swagger是2.9.2的吗,如果不是,建议同学跟课程中的版本保持一致试试

http://img1.sycdn.imooc.com//climg/61248058098c3b0004170119.jpg

祝学习愉快~

  • 提问者 慕UI9436362 #1

    不是版本问题。我用的就是这个版本。

    2021-08-24 13:21:49
  • 好帮手慕阿园 回复 提问者 慕UI9436362 #2

    同学你好,一般该报错是由于swagger的版本跟springboot版本不兼容导致的,如果swagger版本没有问题,则建议同学检查下springboot版本;如果都跟课程中的一致,同学添加了更新目录的代码后对swagger相关代码进行了什么操作,建议同学具体检查下该操作,另外同学可以下载源码,跟源码对照下,看看哪里书写有误,如果没有找到,建议同学将swagger相关代码以及依赖进行反馈

    ​祝学习愉快~

    2021-08-24 16:04:32
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师