DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Auto Logging in Class and Method Level Using Custom Annotations in Spring Boot App
  • Spring Boot Pet Clinic App: A Performance Study
  • Improving Backend Performance Part 1/3: Lazy Loading in Vaadin Apps
  • Advanced Kubernetes Setup for Spring Boot App With PostgreSQL DB

Trending

  • Top Gen AI Frameworks for Go in 2026: A Hands-On Comparison
  • Building a Windows App for a Resilient SSH SOCKS Proxy and Selective Browser Routing
  • OwlVigil Open-Sources Its Go SDK for Enterprise AI
  • Persisting Cookies Across JAX-WS Service Calls Using a Custom SOAP Handler

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Frameworks
  4. Deploying Spring Boot App to JBoss Wildfly

Deploying Spring Boot App to JBoss Wildfly

Learn more about deploying your own Spring Boot app using JBoss Wildfly.

By 
Tapas Joshi
·
Oct. 02, 19 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
112.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

We know that when we create any Spring Boot application, it comes with an embedded Tomcat server, and we have no need to set up the server additionally. This happens because, in the Spring Boot parent project, it has the dependency for Tomcat, and when we start the Spring Boot application, it bootstraps the application with the Tomcat server itself.

But sometimes, our requirements might include creating a war file and then deploying it to any web application server, like JBoss. In this article, we will see how to package a Spring Boot application and deploy it to any external server. Here, we will be using JBoss to perform the following tasks:

  • Create a Spring Boot application
  • Remove the embedded Tomcat server from the application
  • Generate a war file that can be deployed to the JBoss server

Creating a Spring Boot Application

  • You can create a Spring Boot application by generating a project from start.spring.io.
  • Once downloaded, you can import the Maven project to your IDE (Spring Tool Suite is recommended) as an existing Maven project.
  • Then, implement a Maven build to fetch the required dependencies.

Related tutorial: Learn How to Publish Maven Artifacts to Nexus OSS

Separate the Embedded Tomcat Server From the Spring Boot App

  • First of all, open the pom.xml and add the Tomcat dependency. Next, you can change the scope to the provided. When we make the scope as provided that means this dependency will be available during compile time only and will not be available at run-time. This is because we need this dependency in compile time to compile the web-component-related files.

  • Adding the Tomcat dependency and changing the scope to provided will give us the following:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>
<!-- Make sure that you changed the packaging to war -->
 <packaging>war</packaging>
  • Then, extend the SpringBootServletInitializer class in your Spring Boot main class and override the configure method. We need to do this to initialize the application in any other servlet container like JBoss.

  • You can see the code below that extends the SpringBootServletInitializer and overrides the configure method.

@SpringBootApplication
@EnableSwagger2
public class SpringBootDemoApplication extends SpringBootServletInitializer {

  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){
    return builder.sources(SpringBootDemoApplication.class);
  }

  public static void main(String[] args){
    SpringApplication.run(SpringBootDemoApplication.class, args);
  }
}
  • With this configuration, the application is ready to deploy to any external application server.

  • Once this is done, you can package your Spring Boot application as a war and deploy it to the JBoss server. To do that, you need to run  mvn clean package, which will generate the war file. 

Review additional tips for using Maven. That's all for now. We hope you enjoyed this short demonstration. Be sure to leave thoughts and questions in the comments section.

Spring Framework Spring Boot JBoss Web application app WildFly

Opinions expressed by DZone contributors are their own.

Related

  • Auto Logging in Class and Method Level Using Custom Annotations in Spring Boot App
  • Spring Boot Pet Clinic App: A Performance Study
  • Improving Backend Performance Part 1/3: Lazy Loading in Vaadin Apps
  • Advanced Kubernetes Setup for Spring Boot App With PostgreSQL DB

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook