我在tomcat 9上部署了春季启动战时得到了这一点。我尝试了许多解决方案,例如清理项目以及在stackoverflow中找到的每种可能的解决方案,但是没有用,其中之一在web.xml中提供了绝对的排序,但是它是一个春季启动应用程序,因此我不需要使用web.xml文件。该应用程序已与localhost完美配合,当我在服务器上部署war文件时出现了问题。以下是错误。
23-Aug-2019 04:03:25.139 INFO [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/opt/apache-tomcat/webapps/LoopServer.war]
23-Aug-2019 04:03:27.100 SEVERE [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [/opt/apache-tomcat/webapps/LoopServer.war]
java.lang.IllegalStateException: Error starting child
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:716)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1849)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1620)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:305)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1144)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1346)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1350)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1328)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/LoopServer]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
... 25 more
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:2257)
at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2215)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1127)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:768)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:301)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5048)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 26 more
23-Aug-2019 04:03:27.103 INFO [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/opt/apache-tomcat/webapps/LoopServer.war] has finished in [1,964] ms
下面是我的gradle依赖项配置
group 'com.lss.loopserver'
version '1.0-SNAPSHOT'
buildscript {
ext {
springBootVersion = '2.1.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("javax.servlet:javax.servlet-api:4.0.1")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
war {
baseName = 'LoopServer'
version = '0.0.1'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
maven { url "http://repo.spring.io/libs-snapshot" }
}
configurations {
providedRuntime
compile.exclude module: 'spring-boot-starter-tomcat'
all*.exclude module: 'spring-boot-starter-logging'
}
dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.12'
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.boot:spring-boot-starter-data-jpa') {
exclude group: 'com.zaxxer', module: 'HikariCP'
}
implementation('org.springframework.cloud:spring-cloud-starter-oauth2')
implementation('org.springframework.boot:spring-boot-starter-security') {
exclude group: 'org.springframework', module: 'spring-aop'
}
implementation('org.springframework.boot:spring-boot-starter-aop')
implementation("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
providedCompile('javax.servlet:javax.servlet-api:4.0.1')
compile('javax.el:javax.el-api:3.0.0')
compile('javax.validation:validation-api:2.0.1.Final')
compile('org.hibernate:hibernate-validator:5.4.1.Final')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
implementation('javax.inject:javax.inject:1')
implementation('mysql:mysql-connector-java:6.0.6')
implementation('joda-time:joda-time:2.10.2')
implementation ('com.google.code.gson:gson:2.8.1')
implementation group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.3'
implementation ('org.apache.commons:commons-io:1.3.2')
runtime('org.springframework.boot:spring-boot-devtools')
runtime('com.h2database:h2')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Greenwich.RC2"
}
}
bootRun {
sourceResources sourceSets.main
}
application.yml:
server:
port: 8080
servlet:
context-path: /LoopServer
spring:
datasource:
url: jdbc:mysql://${db.host:localhost}:${db.port:3306}/${db.name:loopschool}?useSSL=false
username: ${db.uid:root}
password: ${db.pwd:password}
driver-class-name: com.mysql.cj.jdbc.Driver
tomcat:
test-while-idle: true
validation-query: SELECT 1
type: com.mysql.cj.jdbc.MysqlDataSource
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5Dialect
id:
new_generator_mappings: false
format_sql: true
hibernate:
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
ddl-auto: validate
open-in-view: false
application:
name: LoopServer
jmx:
default-domain: LoopServer
main:
allow-bean-definition-overriding: true
devtools:
livereload:
enabled: false
logging:
level:
org:
hibernate:
SQL: DEBUG
type:
descriptor:
sql:
BasicBinder: TRACE
主类:
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class Main extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Main.class);
}
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}
如果有人知道该错误的任何想法,请帮助我。
答案 0 :(得分:0)
最后我找到了解决方案,看来那里存在一些spring依赖冲突。所以我要做的就是简单地用另一个名字重新创建该项目,然后它开始工作并且错误也消失了。 另一个可能的解决方案是以正确的方式清理服务器(我没有尝试过,但是我认为它可以工作)。
答案 1 :(得分:0)
清洁服务器(在我的情况下是tomcat) 要么 删除tomcat服务器和工件ID。再次配置,它将正常工作