JavaCodingNerd

Java Coding Nerd. This Blog will feature content-rich articles, tutorials and own opinions on variuos programming related topcis.

JavaEE, Uncategorized, Useful Tools

Deployment of a JavaEE Project to Wildfly using Maven

Deployment

Deployment

In this Post we will have a look how we can easily deploy a JavaEE Project to Wildfly using Maven Deployment features

What you should have

In order to complete this tutorial you need the following

  • A JavaEE Maven Project
  • Wildfly (I am using 10.1.0)
  • Maven

In case you dont have any, this blog is still worthwhile reading because you will also learn about Maven Plugins and Execution Goals

Let´s get down to business (Deployment)

Actually there is only one thing you need to add to your pom.xml

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

The next thing you should do is start your Wildlfy Server. If you dont have your IDE configured to do that go to wildfly-10.1.0.Final\bin and start standalone.bat

To confirm that you Server started successfully go to localhost:8080 and check wether the Wildlfy Startpage shows in your Browser.

Deployment using cmd/bash

Now open your cmd/git bash or whatever where your Project is. You should be in the highest Project structure where you pom.xml is.
Type “ls” in your prompt there should the pom.xml be listed.
Now type the following command “mvn clean install wildfly:deploy ”

Now your Project should be deployed on the Server you can check that either in the

wildfly-10.1.0.Final\standalone\deployments

Folder or in the Admin Panel of Wildlfy (Localhost:9990) under deployments

 

Deployment using Eclipse

Right click on the Project -> run as -> Maven Build…
Now type the following command “clean install wildfly:deploy ”

Now your Project should be deployed on the Server you can check that either in the

wildfly-10.1.0.Final\standalone\deployments

Folder or in the Admin Panel of Wildlfy (Localhost:9990) under deployments

Using Execution Goals

You can also configure your pom.xml so that your projects gets deployed everytime u execute a maven goal , like clean or install.
To do that add the following to you pom.xml

<build>
       ...
       <plugins>
           ...
           <plugin>
               <groupId>org.wildfly.plugins</groupId>
               <artifactId>wildfly-maven-plugin</artifactId>
               <version>1.2.0.Final</version>
               <executions>
                   <execution>
                       <phase>install</phase>
                       <goals>
                           <goal>deploy</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>
           ...
       </plugins>
       ...
   </build>

Thats all folks thanks for reading

Spread the love

Leave a Reply

Theme by Anders Norén