I am trying to create a project that uses a java spring back-end and a javascript front-end. I have a parent pom with 2 modules 'webapp' and 'frontend'. how would i package this all into one war to copy onto a local tomcat server?
I know i would have to create one "uber" WAR but i dont know how to do that using maven, any pointers/ links to tutorials on packaging projects like this?
I dont want to put them into one EAR file.
Parent pom
<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>foo</groupId>
<artifactId>barr</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
<modules>
<module>webapp</module>
<module>frontend</module>
</modules>
</project>
You could use a combination of maven-assembly plugin and maven-shade plugin in order to create your final "uber" jar. Although, I think it is a bad idea, according to me you should install TomEE instead of tomcat and deploy a regular EAR it would be painless.
I can see you try to leverage whatever is available on Spring Boot, so it would make sense to work along the way with it, taking advantage of it's automatic configuration /conventions. As far as I know Spring Boot supports the inclusion of static content to an existing war, please see here related question or here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.