找到了多个名为 \[spring_web\] 的片段。这对于相对顺序是不合法的

我有一个 spring boot 应用程序,当我使用 Intellj 的嵌入式服务器运行它时,它运行良好。但是,当我将它打包成 .war 文件并将其部署到 tomcat 上时,出现以下错误:

     org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/file-upload-0.0.1-SNAPSHOT]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)

at

org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)

at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)

at

org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at

java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

Caused by: java.lang.IllegalArgumentException: More than one fragment with the name [spring_web] was found. This is not legal with relative ordering. See section 8.2.2 2c of the Servlet specification for details. Consider using absolute ordering.

at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2200)

at

org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2159)

at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1124)

at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:769)

at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)

at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)

at

org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5176)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

... 10 more

21-Jan-2019 01:51:04.709 SEVERE [localhost-startStop-1]

org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [C:\Users\dennismo\Dev\Projects\Production Prep\file-upload-module\webapps\file-upload-0.0.1-SNAPSHOT.war]

java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/file-upload-0.0.1-SNAPSHOT]]

at

org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:758)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)

at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)

at

org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

我的项目不包含多个网络片段,所以我不知道是什么导致了这个问题。

pom.xml

 <parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>2.1.0.RELEASE</version>

<relativePath/> <!-- lookup parent from salaryPaymentRequestRepo -->

</parent>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<java.version>1.8</java.version>

<akka.version>2.5.17</akka.version>

</properties>

<repositories>

<repository>

<id>default</id>

<url>http://repo.maven.apache.org/maven2</url>

</repository>

</repositories>

<dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-thymeleaf</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-data-jpa</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-starter-tomcat</artifactId>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>com.h2database</groupId>

<artifactId>h2</artifactId>

<version>1.4.197</version>

<scope>compile</scope>

</dependency>

<dependency>

<groupId>com.univocity</groupId>

<artifactId>univocity-parsers</artifactId>

<version>2.7.6</version>

</dependency>

<dependency>

<groupId>org.projectlombok</groupId>

<artifactId>lombok</artifactId>

<optional>true</optional>

</dependency>

<dependency>

<groupId>com.fasterxml.jackson.dataformat</groupId>

<artifactId>jackson-dataformat-xml</artifactId>

<version>2.9.0</version>

</dependency>

<dependency>

<groupId>com.google.guava</groupId>

<artifactId>guava</artifactId>

<version>26.0-jre</version>

</dependency>

<dependency>

<groupId>org.mockito</groupId>

<artifactId>mockito-core</artifactId>

<version>2.23.4</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>com.google.code.gson</groupId>

<artifactId>gson</artifactId>

<version>2.8.5</version>

</dependency>

<dependency>

<groupId>com.squareup.okhttp3</groupId>

<artifactId>okhttp</artifactId>

<version>3.11.0</version>

</dependency>

<dependency>

<groupId>ma.glasnost.orika</groupId>

<artifactId>orika-core</artifactId>

<version>1.4.2</version><!-- or latest version -->

<exclusions>

<exclusion>

<artifactId>javassist</artifactId>

<groupId>org.javassist</groupId>

</exclusion>

</exclusions>

</dependency>

<dependency>

<groupId>com.typesafe.akka</groupId>

<artifactId>akka-actor_2.12</artifactId>

<version>${akka.version}</version>

</dependency>

<dependency>

<groupId>com.typesafe.akka</groupId>

<artifactId>akka-stream_2.12</artifactId>

<version>${akka.version}</version>

</dependency>

<dependency>

<groupId>com.typesafe.akka</groupId>

<artifactId>akka-persistence_2.12</artifactId>

<version>${akka.version}</version>

</dependency>

<dependency>

<groupId>com.typesafe.akka</groupId>

<artifactId>akka-testkit_2.12</artifactId>

<version>${akka.version}</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>com.oracle</groupId>

<artifactId>ojdbc7</artifactId>

<version>12.1.0.2</version>

<scope>system</scope>

<systemPath>${basedir}/src/main/resources/lib/ojdbc7-12.1.0.jar</systemPath>

</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

</plugin>

</plugins>

</build>

原文由 user2054833 发布,翻译遵循 CC BY-SA 4.0 许可协议


回答:

听起来您有两个不同版本的 Spring,请检查您的依赖项以查看您是否依赖于另一个 Spring 版本。

 mvn dependency:tree -Dverbose -Dincludes=groupId:artifactId

原文由 David Simonsbacka 发布,翻译遵循 CC BY-SA 4.0 许可协议


回答:

添加 <absolute-ordering /> 标签到你的 web.xml 就在 <display-name> 标签下。应该管用。

原文由 Roman Sterlin 发布,翻译遵循 CC BY-SA 4.0 许可协议


回答:

重新mvn clean

mvn package 即可 如果还不行就idea 再重新reimport一下

以上是 找到了多个名为 \[spring_web\] 的片段。这对于相对顺序是不合法的 的全部内容, 来源链接: utcz.com/p/944845.html

回到顶部