0

I am trying to make a WAR file to deploy on tomcat out of a Spring Boot project using maven from the command line.

I have already made the modifications to the POM file recommended here: http://blog.codeleak.pl/2014/04/how-to-spring-boot-and-thymeleaf-with-maven.html

However, when I explode the resulting WAR file I see a file structure like this:

META-INF/  
org/  
WEB-INF/ 

which is different from what IntelliJ outputs:

META-INF/  
WEB-INF/  

Additionally there are many missing folders and files in the WEB-INF folder, like the application.properties file.

What am I missing? I have struggled with this all day...

The project code base is basically contained in two folders

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

This is the POM file:

<?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>
Panciz
  • 2,183
  • 2
  • 30
  • 54
bredman
  • 3
  • 4
  • Please provide some code, for example your pom file and tour project structure – Panciz Jul 13 '17 at 00:55
  • Hi, you can see in the body of my question the POM file now. The code is basically contained in two folders: src/main/com/../packagename and src/main/resources. Thanks. – bredman Jul 13 '17 at 01:44
  • So the maven created with the command lines maven looks like more complete? Does it works? Maybe it is just a Intellij issues, it does not recognizes the project as a web project! – Panciz Jul 13 '17 at 01:49
  • actually it does not work or I don't know how to make it work. I want to deploy it in an external tomcat but it seems like it's missing files compared to the WAR produced by intelliJ. For instance, I don't know how to configure the connection with the database because there is no application.properties file. Also there are three missing folders in WEB-INF/classes: META-INF, public and templates. I don't understand what is going on. – bredman Jul 13 '17 at 01:56
  • Pay attention you are including only *.jasper file, maybe this is the problem. – Panciz Jul 13 '17 at 02:00
  • you are right! Thank you so much! – bredman Jul 13 '17 at 02:11

1 Answers1

0

Trying including all the resources not just the *.jasper files

    <resources>
        <resource>
            <directory>src/main/java</directory>
          <!--  <includes> -->
          <!--      <include>**/*.jasper</include> -->
         <!--   </includes> -->
        </resource>
    </resources>
Panciz
  • 2,183
  • 2
  • 30
  • 54
  • I don't know who added that restriction in there... For some reason intelliJ just ignored it. Thanks! – bredman Jul 13 '17 at 02:17