Run Java web applications with WildFly Maven Plugin

JBoss WildFly is a Java server runtime that makes it possible to run Java web applications. To facilitate the development process, you can use WildFly Maven Plugin to run the web application we are working on using Maven right away, no need to build the source code into a .war file and then copy it to the deployment directory of JBoss WildFly. In this tutorial, I will show you how to use this WildFly Maven Plugin!

I will create a new Spring MVC project as follows:

Because in Maven Archetype huongdanjava-springmvc-archetype, I have defined to use the Maven Jetty plugin to run this application, so I will remove this plugin, instead, I will declare to use WildFly Maven Plugin as follows:

By default, WildFly Maven Plugin will download and use the latest version of JBoss WildFly to run the application. You can specify the JBoss WildFly version that you want to use by declaring the configuration as follows:

The information in the <version> tag above is the version of JBoss WildFly that you want to use.

For my example application with Spring framework 6.x running with Java 17 and Jakarta EE 9, only JBoss WildFly version 27.0.1.Final is suitable, so I will declare my example as follows:

Now, if you run this application with Maven goals as mvn clean package wildfly:run, you will see the following results in the Console:

So our application has been deployed successfully. The context path of the application, as you can see in the log message above, is /wildfly-maven-plugin-example-1.0-SNAPSHOT!

The result when I request to the address http://localhost:8080/wildfly-maven-plugin-example-1.0-SNAPSHOT/ is as follows:

 

Add Comment