在部署到JBOSS时从war文件中删除嵌入式tomcat服务器[Spring-Boot]

时间:2016-11-23 17:16:13

标签: spring-boot jboss

我正在使用intellij而不是从war文件中手动删除tomcat jar,这是在编译期间删除它们的更好方法。

我需要这样做,因为我收到以下错误:

failure description: {"WFLYCTL0080: Failed services" =>    
{"jboss.undertow.deployment.default-server.default-host.\"/request-ws-
0.0.1-SNAPSHOT\"" => "org.jboss.msc.service.StartException in service 
jboss.undertow.deployment.default-server.default-host.\"/request-ws-
0.0.1-SNAPSHOT\": java.lang.RuntimeException: 
java.lang.ClassCastException: 
org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to 
io.undertow.websockets.jsr.ServerWebSocketContainer

然而,当我删除tomcat jar时,一切都很好。

我正在使用Gradle,我想在使用JBOSS运行它时删除tomcat。但是,当我使用spring-boot运行它时,我想要/需要它。

1 个答案:

答案 0 :(得分:1)

如果您使用maven,则需要在provided中将tomcat依赖范围设置为pom.xml,如http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging

中所述
<?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">
    <!-- ... -->
    <packaging>war</packaging>
    <!-- ... -->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- ... -->
    </dependencies>
</project>

Gradle用户应使用http://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-gradle-plugin.html中描述的providedRuntime

...
apply plugin: 'war'

war {
    baseName = 'myapp'
    version =  '0.5.0'
}

repositories {
    jcenter()
    maven { url "http://repo.spring.io/libs-snapshot" }
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
    ...
}