MVN springboot插件输出错误的tomcat可部署WAR

时间:2017-07-12 22:17:15

标签: maven tomcat war spring-boot-maven-plugin

我正在尝试使用maven从命令行创建一个WAR文件,以便在Spring Boot项目的tomcat上部署。

我已经对这里推荐的POM文件进行了修改: http://blog.codeleak.pl/2014/04/how-to-spring-boot-and-thymeleaf-with-maven.html

但是,当我分解生成的WAR文件时,我会看到如下文件结构:

META-INF/  
org/  
WEB-INF/ 

与IntelliJ输出的不同:

META-INF/  
WEB-INF/  

此外,WEB-INF文件夹中有许多丢失的文件夹和文件,例如application.properties文件。

我错过了什么?我一整天都在努力......

项目代码库基本上包含在两个文件夹中

src/main/com/.../packagename  
src/main/resources

这是POM文件:

<?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.packagename</groupId>
    <artifactId>findeme</artifactId>
    <version>1.0.0</version>
    <packaging>war</packaging>

    <repositories>
        <repository>
            <id>marketpower</id>
            <url>https://github.com/marketpower/sdk-java/raw/master/releases</url>
        </repository>
    </repositories>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.3.RELEASE</version>
        <relativePath />
    </parent>

    <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-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-messaging</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.nekohtml</groupId>
            <artifactId>nekohtml</artifactId>
            <version>1.9.21</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <!-- TOMCAT -->
        <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>

        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>6.1.0</version>
        </dependency>
        <dependency>
            <groupId>net.sf.barcode4j</groupId>
            <artifactId>barcode4j</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlgraphics</groupId>
            <artifactId>batik-bridge</artifactId>
            <version>1.7</version>
        </dependency>
        <dependency>
            <groupId>net.sargue</groupId>
            <artifactId>mailgun</artifactId>
            <version>1.4.0</version>
        </dependency>

        <!-- payments -->
        <dependency>
            <groupId>com.marketpower</groupId>
            <artifactId>sdk</artifactId>
            <version>0.3.4</version>
        </dependency>

    </dependencies>

    <properties>
        <start-class>com.packagename.findeme.App</start-class>
        <java.version>1.8</java.version>
    </properties>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.jasper</include>
                </includes>
            </resource>
        </resources>
    </build>

</project>

1 个答案:

答案 0 :(得分:0)

尝试包含所有资源,而不仅仅是*.jasper个文件

    <resources>
        <resource>
            <directory>src/main/java</directory>
          <!--  <includes> -->
          <!--      <include>**/*.jasper</include> -->
         <!--   </includes> -->
        </resource>
    </resources>