Generate War file using Maven

We Are Going To Discuss About Generate War file using Maven . So lets Start this Java Article.

Generate War file using Maven

Advertisements
  1. Generate War file using Maven

    Project > run as > run config > maven build in left panel > right click > new > goal > clean install > base directory> select your current project workspace.> apply> run

  2. Generate War file using Maven

    Project > run as > run config > maven build in left panel > right click > new > goal > clean install > base directory> select your current project workspace.> apply> run

Solution 1

Advertisements

First you must define your project with as packaging of war type:

<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<packaging>war</packaging>

Then you will need to use the maven plugin to generate the war when compiling:

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <attachClasses>true</attachClasses>
        <webXml>target/web.xml</webXml>
        <webResources>
            <resource>
                <directory>src/main/webapp</directory>
                <filtering>true</filtering>
            </resource>
        </webResources>
    </configuration>
</plugin>

Original Author Sergio Gragera Of This Content

Solution 2

Advertisements

Try running clean install or clean package maven command.

Project > run as > run config > maven build in left panel > right click > new > goal > clean install > base directory> select your current project workspace.> apply> run

same way for clean package or any other maven command.

if it gives BUILD SUCCESS then fine otherwise put that error code here in the question.

Original Author R Dhaval Of This Content

Solution 3

Advertisements

one solution is just to use a maven-war-plugin(https://maven.apache.org/plugins/maven-war-plugin/index.html)

Original Author Mobility Of This Content

Conclusion

Advertisements

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment