How can we create a single war file for multiple or diif application code and deoply on single aws enviornment?
Asked
Active
Viewed 72 times
0
-
What type of project do you have? maven? sbt? There are different ways in which you can do this for each type of projects. – papaya Dec 24 '19 at 05:04
-
maven ......... – Vikas Kumar Dec 24 '19 at 05:23
2 Answers
1
Add this to your pom.xml
to create war file later to be deployed anywhere!
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-my-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

papaya
- 1,505
- 1
- 13
- 26
0
The accepted answer explains in general terms how to create a WAR file in Maven.
However you are asking how to create a WAR file for "multiple or diff[erent] application code". The answer depends on what you mean.
If you mean a single webapp that has multiple components and / or dependencies, then the accepted answer should work.
If you mean a multiple webapps ... there is a problem. A WAR contains a single webapp. There is only one
WEB-INFO
tree and only oneweb.xml
file in a WAR file. So your options are:- Create and deploy multiple WAR files.
- Try to integrate the separate webapps into a single webapp. This could be as simple as rewriting the
web.xml
files and combining the WEB-INFO trees. Or it could be more complicated. Then create the WAR for the combined webapp. - If your web container supports this, you could create and deploy an EAR file containing multiple webapps; see .war vs .ear file

Stephen C
- 698,415
- 94
- 811
- 1,216