Maven 3 – How to deploy a WAR package

When you are using an auto deploy directory of an application server have you ever wondered how much time you waste while switching through windows while building and deploying web application while working on it? You can easily configure maven 3 to deploy WAR application package after it has been created. Just enter following code in your pom.xml file.
Replace [PACKAGE_FILE_NAME] with your WAR package name.
Replace [APPSERVER_AUTO_DEPLOY_DIRECTORY] with a path to your app servers auto deploy directory.

pom.xml

<build> 
    <plugins>
		<plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy_package</id>
                    <phase>install</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <tasks>
                            <copy file="target/[PACKAGE_FILE_NAME]"
                                todir="[APPSERVER_AUTO_DEPLOY_DIRECTORY]" />
                        </tasks>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

This configuration is copying application package file to your application servers auto deploy directory.

One Response to "Maven 3 – How to deploy a WAR package"

  1. TUSHAR PATEL says:

    Thanks It is work for me.

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>