首页 文章

无法启动嵌入式Tomcat NoClassDefFoundError DispatcherServletPath

提问于
浏览
0

我的 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服务器;嵌套异常是org.springframework.boot.web.server.WebServerException:无法在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155)〜[spring-boot-2.0]启动嵌入式Tomcat .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 . 发布org.springframework上的org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)~ [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] . 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.REL EASE.jar:2.0.4.RELEASE] org.springframework上的org.springframework.boot.SpringApplication.run(SpringApplication.java:1258)[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] .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:无法在org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126)启动嵌入式Tomcat~ [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] at 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.getWe bServer(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:在类路径资源中定义名为'servletEndpointRegistrar'的bean时出错[org / springframework / boot / actuate / autoconfigure / endpoint / web / ServletEndpointManagementContextConfiguration $ WebMvcServletEndpointManagementContextConfiguration.class]:通过工厂方法的Bean实例化失败;嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]:工厂方法'servletEndpointRegistrar'抛出异常;嵌套异常是java.lang.NoClassDefFoundError:org / springframework / boot / autoconfigure / web / servlet / DispatcherServletPath at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:590)~ [spring-beans-5.0 .8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1247)〜[spring-beans-5.0.8.RELEASE.jar:5.0 . 8.RELEASE] org.springframework上的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.createBean上的beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] (AbstractAutowireCapableBeanF actory.java:495)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] atorg.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 . or.s.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory)中的factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] .java:315)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)〜[spring- bean-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:226)~ [spring-boot-2.0.4.RELEASE.jar :2.0.4.RELEASE] at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:214)〜[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] a 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的org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)〜[tomcat-embed-core-8.5.32.jar:8.5.32] . catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1421)〜[tomcat-embed-core-8.5.32.jar:8.5.32] at org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase) .java:1411)〜[tomcat-embed-core-8.5.32.jar:8.5.32] at java.util.concurrent.FutureTask.run(FutureTask.java:266)〜[na:1.8.0_131] at java .util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)〜[na:1.8.0_131] at 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.actuate.endpoint.web . ServletEndpointRegistrar]:工厂方法'servletEndpointRegistrar'抛出异常;嵌套异常是java.lang.NoClassDefFoundError:org / springframework / boot / autoconfigure / web / servlet / DispatcherServletPath at 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 at 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.ServletEndpo intManagementContextConfiguration $ WebMvcServletEndpointManagementContextConfiguration $$ EnhancerBySpringCGLIB $$ a6542fda.CGLIB $ servletEndpointRegistrar $ 0()〜[spring-boot-actuator-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE] org.springframework.boot.actuate.autoconfigure .endpoint.web.ServletEndpointManagementContextConfiguration $ WebMvcServletEndpointManagementContextConfiguration $$ EnhancerBySpringCGLIB $$ a6542fda $$ FastClassBySpringCGLIB $$ dc5ad488.invoke()〜[spring-boot-actuator-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE] atorg.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] at org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration $ WebMvcServletEndpointManagementContextConfiguration $$ EnhancerBySpringCGLIB $$ a6542fda.servletEndpointRegistrar()〜[spring-boot-actuator-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)〜[na:1.8.0_131 ]在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)〜[na:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)〜[na:1.8.0_131] at java . org.springframework.beans.factory.support.Si中的lang.reflect.Method.invoke(Method.java:498)〜[na:1.8.0_131] mpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)〜[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] ... 24个常用框架省略引起:java.lang.ClassNotFoundException:org.springframework . java.lang.ClassLoader.loadClass(ClassLoader.java:424)〜[na] java.net.URLClassLoader.findClass(URLClassLoader.java:381)〜[na:1.8.0_131]的boot.autoconfigure.web.servlet.DispatcherServletPath :1.8.0_131] at sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:335)〜[na:1.8.0_131] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)〜[na:1.8 .0_131] ...省略了35个常用帧

nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/autoconfigure/web/servlet/DispatcherServletPath

我发现,问题出在 spring-cloud-starter-oauth2 依赖 . 如果我删除它,一切正常 . 我该如何解决这个问题?

2 回答

  • 0

    M. Deinum的评论帮助我解决了这个问题

    对于初学者停止混合相同框架的版本(2.0.4和2.0.2) . 要覆盖hibernate版本,请将5.3.5.Final添加到元素并删除hibernate依赖项 . 注意:在Spring Boot 2.0.4中添加了DispatcherServletPath,因此可能是您的版本不匹配是此问题的根本原因

  • 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>
    

相关问题