我的 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.qroom</groupId>
<artifactId>qroom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>qroom</name>
<description>qRoom Server</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.5.Final</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.23.1</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
启动我的应用程序时,出现以下错误:
org.springframework.context.ApplicationContextException:无法启动Web服务器;无法启动Web服务器。嵌套的异常是org.springframework.boot.web.server.WebServerException:无法启动嵌入式Tomcat 在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)〜[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762)上[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398)上[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:330)[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1258)上[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)上[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在com.qroom.QroomApplication.main(QroomApplication.java:10)[classes /:na] 引起原因:org.springframework.boot.web.server.WebServerException:无法启动嵌入式Tomcat 在org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.web.embedded.tomcat.TomcatWebServer。(TomcatWebServer.java:86)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:413)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] ...省略了8个通用框架 由以下原因引起:org.springframework.beans.factory.BeanCreationException:在类路径资源[org / springframework / boot / actuate / autoconfigure / endpoint / web / ServletEndpointManagementContextConfiguration $ WebMvcServletEndpointManagementContextConfiguration.class]中创建名称为“ servletEndpointRegistrar”的bean时出错。通过工厂方法失败;嵌套的异常是org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.boot.act.ateu.endpoint.web.ServletEndpointRegistrar]:工厂方法servletEndpointRegistrar抛出了异常;嵌套的异常是java.lang.NoClassDefFoundError:org / springframework / boot / autoconfigure / web / servlet / DispatcherServletPath 在org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:590)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1247)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0(AbstractBeanFactory.java:317)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:226)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:214)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:91)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.web.servlet.ServletContextInitializerBeans。(ServletContextInitializerBeans.java:80)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:250)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:237)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:54)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] 在org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5245)〜[tomcat-embed-core-8.5.32.jar:8.5.32] 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)〜[tomcat-embed-core-8.5.32.jar:8.5.32] 在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1421)〜[tomcat-embed-core-8.5.32.jar:8.5.32] 在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1411)〜[tomcat-embed-core-8.5.32.jar:8.5.32] 在java.util.concurrent.FutureTask.run(FutureTask.java:266)〜[na:1.8.0_131] 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)〜[na:1.8.0_131] 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)〜[na:1.8.0_131] 在java.lang.Thread.run(Thread.java:748)〜[na:1.8.0_131] 由以下原因引起:org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.boot.act.ateu.endpoint.web.ServletEndpointRegistrar]:工厂方法servletEndpointRegistrar抛出异常;嵌套的异常是java.lang.NoClassDefFoundError:org / springframework / boot / autoconfigure / web / servlet / DispatcherServletPath 在org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] ...省略了23个通用框架 造成原因:java.lang.NoClassDefFoundError:org / springframework / boot / autoconfigure / web / servlet / DispatcherServletPath 在org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration $ WebMvcServletEndpointManagementContextConfiguration.servletEndpointRegistrar(ServletEndpointManagementContextConfiguration.java:71)〜[spring-boot-actuator-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE ] 在org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration $ WebMvcServletEndpointManagementContextConfiguration $$ EnhancerBySpringCGLIB $$ a6542fda.CGLIB $ servletEndpointRegistrar $ 0()〜[spring-boot-actuator-autoconfigure-2.0.4.RELEASE.2.0: .4.RELEASE] 在org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration $ WebMvcServletEndpointManagementContextConfiguration $$ EnhancerBySpringCGLIB $$ a6542fda $$ FastClassBySpringCGLIB $ dc5ad488.invoke()〜[spring-boot-actuator-autoconfigure-2。 jar:2.0.4.RELEASE] 在org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)〜[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.context.annotation.ConfigurationClassEnhancer $ BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)〜[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE] 在org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration $ WebMvcServletEndpointManagementContextConfiguration $$ EnhancerBySpringCGLIB $$ a6542fda.servletEndpointRegistrar()〜[spring-boot-actuator-autoconfigure-2.0.4.RELEASE.jar:2.0.4。发布] 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[na:1.8.0_131] 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)〜[na:1.8.0_131] 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)〜[na:1.8.0_131] 在java.lang.reflect.Method.invoke(Method.java:498)〜[na:1.8.0_131] 在org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] ...省略了24个通用框架 引起原因:java.lang.ClassNotFoundException:org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath 在java.net.URLClassLoader.findClass(URLClassLoader.java:381)〜[na:1.8.0_131] 在java.lang.ClassLoader.loadClass(ClassLoader.java:424)〜[na:1.8.0_131] 在sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:335)〜[na:1.8.0_131] 在java.lang.ClassLoader.loadClass(ClassLoader.java:357)〜[na:1.8.0_131] ...省略了35个通用框架
嵌套异常是java.lang.NoClassDefFoundError:org / springframework / boot / autoconfigure / web / servlet / DispatcherServletPath
我发现了,这个问题是 spring-cloud-starter-oauth2 依赖项。如果我将其移除,则一切正常。我该如何解决这个问题?
答案 0 :(得分:0)
如果不使用dependencyManagement
,Maven将无法解决不依赖版本的依赖关系。为org.springframework.cloud
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
答案 1 :(得分:0)
M。 Deinum的评论帮助我解决了问题
对于初学者,请停止混合使用同一框架的版本(2.0.4和2.0.2)。要覆盖休眠版本,请向元素添加5.3.5.Final并删除休眠依赖项。注意:DispatcherServletPath是在Spring Boot 2.0.4中添加的,因此您的版本不匹配可能是导致此问题的根本原因