DEV Community

Cover image for Deploy Spring Boot on WildFly application server

Posted on • Updated on

Deploy Spring Boot on WildFly application server

By default Spring Boot comes with embedded Tomcat server, which, when build as fat jar enables deploying application as simple as running java -jar command. But one could also use some other JavaEE or application server for deployment. Let's look how to deploy Spring Boot project to WildFly.


For most of the time deploying Spring Boot on application server like WildFly does not actually makes sense since embedded servers (Tomcat by default, Jetty,...) are part of Spring Boot itself.

Deploying Spring Boot project to WildFly will be divided into three parts:

  1. Setting up WildFly (standalone edition)
  2. Setting up and configuring new Spring Boot project
  3. Building Spring Boot project and deploying

1. Setting up WildFly

Firstly download WildFly application server, after download is complete unzip archive, save it and open terminal in WildFly directory.

Next step is setting up WildFly user, with terminal move into bin sub directory and run ./ on Linux or add-user.bat on Windows. Then simply follow those steps:

> What type of user do you wish to add?
a (Management User)

> Enter the details of the new user to add.
Username: wildfly
Password: w1ldFly!
Re-enter Password : w1ldFly!

> What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: <LEAVE BLANK>

> Is this correct yes/no?

> yes/no?

> Press any key to continue . . .
Enter fullscreen mode Exit fullscreen mode

With tha done, we can run WildFly server using ./ (Linux) or .\standalone.bat (Windows). When initialization is completed you should see log:

15:28:47,740 INFO  [] (Controller Boot Thread) WFLYSRV0051: Admin console listening on
Enter fullscreen mode Exit fullscreen mode

Now enter into the browser, after entering admin credentials (defined in previous step) you should see WildFly admin console:

Alt Text

With this we are done setting WildFly server and we are moving on to setting up Spring Boot project.

2. Setting up and configuring Spring Boot project

Alt Text

Firstly let's create project on Spring Boot website, here the only important thing is choosing War as packaging. And also Maven if you want to follow next steps.

Then click Generate button, download, unzip archive and import project into your favourite IDE (I will be using IntelliJ, but you could also use Eclipse, NetBeans, VSCode or anything else).

For testing purposes, we will be creating a simple HelloWorld API endpoint. Let's create Java file under /src/main/java// in it write following code (package and imports are not shown for readbility, but at the end of this article I posted Git repository with source code):

public class HelloApi {

    public String hello() {
        return "Hello from Spring Boot";
Enter fullscreen mode Exit fullscreen mode

You could try building (mvn clean package) and running (java -jar /target/<APP-NAME>.jar). While accessing http://localhost:8080/hello you should see Hello from Spring Boot.

Alt Text

Now let's configure Spring Boot project to deploy it on WebFly. Firstly we will remove Tomcat embedded server from out project. In the pom.xml find spring-boot-starter-tomcat dependency and make sure that <scope> is set to provided if not set it:

Enter fullscreen mode Exit fullscreen mode

And lets exclude some logging libraries that may break deployment:

Enter fullscreen mode Exit fullscreen mode

Next thing we will add some WildFly properties:

Enter fullscreen mode Exit fullscreen mode

Let's break it down: java.version defines JDK version that project is build upon (it is already set), deploy.wildfly.XX are properties that we need for deploying app on WildFly, host and port are where WildFly is "living", username and password are same as defined in previous step.

Lets use them in build plugin:

Enter fullscreen mode Exit fullscreen mode

With that done make sure everything is still building (run mvn clean package) and lets move on to the next step.

Last thing we will do in our Spring Boot project is setting up context root path (we will set it up to / so our app will be available on Firstly create new file under /src/main/webapp/WEB-INF/jboss-web.xml secondly add to the file:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns=""
Enter fullscreen mode Exit fullscreen mode

Here the only important part is <context-root>/</context-root> where we define context-root.

With this out of the way we build out project (mvn clean package) and deploy our Spring Boot project to WildFly server.

3. Deploying Spring Boot to WildFly

After succesful build you should find .war file in /target directory, this is our project's final form that we will deploy to WildFly.

In WildFly's admin console chose Deployments in navbar and then Upload Deployment.

Alt Text

Now all we have to do is uplaod war file and deploy it.

Alt Text

After successful deployment you could go to and see our final result.

Alt Text

We could (and should) skip last step altogether and simply use Maven for deploying to WildFly by using

mvn clean install

Source code is available on GitHub

Cover photo by Min An from Pexels

Top comments (9)

jeanpierm profile image
Jeanpier Mendoza

Careful, is jboss-web.xml, no jboss-xeb.xml

jakmar17 profile image

Yes! Thank you, fixed

jeanpierm profile image
Jeanpier Mendoza

Thanks to you!

cesarmtnz profile image

I perform these steps but when testing the deployment I have error 403 Forbidden, will it be that for Java 17 are other configurations?

luisfsolano profile image
Luis Fernando Solano Calderon • Edited

in this case after all this time what would be the correct use of continuous delivery (cd) with wildfly. In this case with gitlab.

jakmar17 profile image

Interesting, could you describe how your deploy process is different?