How to deploy multiple wars using tomcat plugin in maven

In the following forums, I tried to find a way to deploy mutliple wars using the tomcat plugin in maven, but I could not succeed.

I created a third project and used three projects to deploy them, but I did not. Could you tell me how to do this?

Best wishes Alper Kopuz

Here is the pom.xml that I used:

<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> tr.com.provus.pays </groupId> <artifactId>PAYSGroupProject</artifactId> <version>1.0</version> <packaging>pom</packaging> <modules> <module>../PAYSWeb</module> <module>../PAYSDashboard</module> <module>../PAYSStaticWeb</module> </modules> <name>PAYSGroupProject</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <executions> <execution> <id>deploy</id> <phase>pre-integration-test</phase> <goals> <goal>run</goal> </goals> </execution> </executions> <configuration> <warSourceDirectory>WebContent</warSourceDirectory> </configuration> </plugin> </plugins> </build> </project> 
+4
source share
2 answers

I think you cannot use the tomcat plugin in a project like pom, try setting up the plugin in one of the military projects instead and include the others as webapp dependencies with something like this:

 <configuration> <webapps> <webapp> <contextPath>/PAYSWeb</contextPath> <groupId>tr.com.provus.pays</groupId> <artifactId>PAYSWeb</artifactId> <version>${project.version}</version> <type>war</type> <asWebapp>true</asWebapp> </webapp> <webapp>...</webapp> </webapps> </configuration> 

Look also at the message (but no reply)

+4
source

Each webapp will need a different root context, which comes with the tomcat7 maven plugin with a path value.

You deploy each web application from your own POM yourself. But since you have a project like pom that forces others to create, you should be able to redeploy all three at once.

Please note that there are two ways to use this plugin:

  • You can deploy without war. It simply compiles java files and deploys them directly to tomcat.
  • You can launch a war. Maven will have to build a war, and then it will be deployed to Tomcat. This is more like deployment of production and helps to verify the correctness of the deployment of war.

So. Transfer your XML plugin to each of the three β€œmodules” of pom files. They will have a type of war. Then add this configuration:

 <path>paysWeb</path> 

under the <configuration> for the first "module". Of course, you use different names for the <path> for each of the modules.

Here's more info: http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/usage.html

+1
source

Source: https://habr.com/ru/post/1485452/


All Articles