Deploy WAR to Wildfly using Maven

Imagine you write a Java Web Application and now you want to deploy it to your local Wildfly installation using Maven.

This small tutorial will teach you how to do that.

 

Configuration of Wildfly Maven Plugin

All you have to do is add the Wildfly Maven Plugin (Version 1.2.1.Final) in your pom.xml file.
But be carefull, we will not place it in the dependency section of our pom.xml, we will bring it to our <build> section, as follow:

<build>
    ...
    <plugins>
        ...
        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>1.2.1.Final</version>
        </plugin>
        ...
    </plugins>
    ...
</build>

So that is the main “hard work”.

 

Deploy your Application

If your Wildfly Installation is listening on the default Port (Port 8080) you can now deploy your application. Doing this you open a Command Line Interface in your project directory and type:

mvn wildfly:deploy

Please ensure that your Wildfly is running.
Maven will now build your project and subsequently deploy it to your local Wildfly instance.

 

Check the Deployment

You can check the success of your deployment by looking on the Wildfly Deployment Dashboard:

 

 

Hint: Changed Wildfly Port

Maybe your Wildfly has a changed Port because the Default Port 8080 is used by another Application, then you have to specify a changed Port for your Deployment.

This can be done by adding the <configuration> and <port> Tag to your Wildfly Maven Plugin:

<build>
     <finalName>heroProducer</finalName>
     <plugins>
         <plugin>
             <groupId>org.wildfly.plugins</groupId>
             <artifactId>wildfly-maven-plugin</artifactId>
             <version>1.2.1.Final</version>
             <configuration>
                 <port>10040</port>
             </configuration>
         </plugin>
     </plugins>
 </build>

 

 

So thanks for reading and have fun using the Wildfly Maven Plugin.

 

Feel free to share