How to deploy Spring boot application to JBOSS application server

How to deploy Spring boot application to JBOSS application server

Create a spring boot application

Open pom.xml and add the below dependency. As you see we added spring-boot-starter-tomcat and set the scope to provided. This is to compile web related components. Make sure the packaging is WAR.

<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>

Extend SpringBootServletInitializer class in your Spring boot main class and override 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 be deployed to any external application server.
Run mvn clean package which generates the WAR and deploy it to JBOSS application server.


Comments

Popular posts from this blog

Bash - Execute Pl/Sql script from Shell script

Gradle Fundamentals

Load Balancing using Spring Cloud Netflix Ribbon