环境:jdk1.8
开发工具:IDEA
说明:今天在做springboot集成swagger2的时候,在启动程序的时候,报错
报错信息:
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug‘ enabled. 2019-02-24 19:32:26.026 ERROR 8660 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:879) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163) ~[spring-boot-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.1.RELEASE.jar:2.1.1.RELEASE] at com.xb.SpringbootDemoApplication.main(SpringbootDemoApplication.java:11) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_152] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_152] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_152] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_152] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.1.RELEASE.jar:2.1.1.RELEASE] Caused by: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2199) ~[guava-16.0.jar:na] at com.google.common.cache.LocalCache.get(LocalCache.java:3934) ~[guava-16.0.jar:na] at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) ~[guava-16.0.jar:na] at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) ~[guava-16.0.jar:na] at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) ~[guava-16.0.jar:na] at springfox.documentation.spring.web.scanners.CachingOperationReader.read(CachingOperationReader.java:57) ~[springfox-spring-web-2.6.1.jar:2.6.1] at springfox.documentation.spring.web.scanners.ApiDescriptionReader.read(ApiDescriptionReader.java:66) ~[springfox-spring-web-2.6.1.jar:2.6.1] at springfox.documentation.spring.web.scanners.ApiListingScanner.scan(ApiListingScanner.java:89) ~[springfox-spring-web-2.6.1.jar:2.6.1] at springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan(ApiDocumentationScanner.java:70) ~[springfox-spring-web-2.6.1.jar:2.6.1] at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.scanDocumentation(DocumentationPluginsBootstrapper.java:85) ~[springfox-spring-web-2.6.1.jar:2.6.1] at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:127) ~[springfox-spring-web-2.6.1.jar:2.6.1] at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE] ... 19 common frames omitted Caused by: java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects at springfox.documentation.swagger.readers.operation.OperationImplicitParameterReader.maybeGetModelRef(OperationImplicitParameterReader.java:74) ~[springfox-swagger-common-2.6.1.jar:2.6.1] at springfox.documentation.swagger.readers.operation.OperationImplicitParameterReader.implicitParameter(OperationImplicitParameterReader.java:59) ~[springfox-swagger-common-2.6.1.jar:2.6.1] at springfox.documentation.swagger.readers.operation.OperationImplicitParameterReader.readParameters(OperationImplicitParameterReader.java:89) ~[springfox-swagger-common-2.6.1.jar:2.6.1] at springfox.documentation.swagger.readers.operation.OperationImplicitParameterReader.apply(OperationImplicitParameterReader.java:50) ~[springfox-swagger-common-2.6.1.jar:2.6.1] at springfox.documentation.spring.web.plugins.DocumentationPluginsManager.operation(DocumentationPluginsManager.java:123) ~[springfox-spring-web-2.6.1.jar:2.6.1] at springfox.documentation.spring.web.readers.operation.ApiOperationReader.read(ApiOperationReader.java:73) ~[springfox-spring-web-2.6.1.jar:2.6.1] at springfox.documentation.spring.web.scanners.CachingOperationReader$1.load(CachingOperationReader.java:50) ~[springfox-spring-web-2.6.1.jar:2.6.1] at springfox.documentation.spring.web.scanners.CachingOperationReader$1.load(CachingOperationReader.java:48) ~[springfox-spring-web-2.6.1.jar:2.6.1] at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) ~[guava-16.0.jar:na] at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) ~[guava-16.0.jar:na] at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) ~[guava-16.0.jar:na] at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) ~[guava-16.0.jar:na] ... 30 common frames omitted Caused by: java.lang.ClassNotFoundException: com.google.common.base.MoreObjects at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_152] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_152] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_152] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_152] ... 42 common frames omitted
看到这一句,经过查询,发现是改报错原因是缺少包,但是我项目中使用的maven,这个包是有的,但是看了一下,JAVA_HOME目录下的/jre/lib/ext目录下是没有guava-23.0.jar这个包,从网上下载这个包复制到ext目录下重新启动程序就好了。
原文地址:https://www.cnblogs.com/Gxiaobai/p/10427583.html
时间: 2024-10-03 20:32:34