不带tomcat的春季启动大战 [英] spring boot war without tomcat embedded

查看:78
本文介绍了不带tomcat的春季启动大战的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个不带maven嵌入式tomcat的war文件. 这是我pom的相关部分

I want to create a war file without embedded tomcat with maven. Here the relevant part of my pom

...
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.1.6.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <!-- Add tomcat only if I want to run directly -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
...

但是如果我运行mvn软件包,我会大战一场,其中tomcat * .jar位于提供的lib文件夹中,但仍位于lib文件夹中.我阅读了 build-tool-plugins -maven-packaging ,但找不到问题所在.

How ever if I run mvn package I get a war, where the tomcat*.jar are in a provided-lib folder but still in the lib-folder. I read build-tool-plugins-maven-packaging, but can't find what's wrong.

我知道一个主要想法是将其作为应用程序运行,无论我们的客户如何将其部署在他的应用程序服务器上.

I know a main idea is to run it as an application, how ever our customer want's to deploy it on his application-server.

推荐答案

跟随Deinum的提示,我排除了tomcat-depedency.

Following the Hint from M. Deinum I excluded the tomcat-depedency.

使用以下pom.xml(相关代码段),maven clean package具有我想要的结果.

With the following pom.xml (relevant snippet) a maven clean package has the result I want to get.

...
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.1.6.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <!-- Add tomcat only if I want to run directly -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
...

对想法用户的警告:您必须在运行配置中激活在提供的范围内包含依赖项"(请参阅​​

Warning for idea-user: You must activate "Include dependencies with the provided scope" in the run-configuration (see Unable to start spring-boot application in IntelliJ Idea for more information)

这篇关于不带tomcat的春季启动大战的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆