Spring Boot for war

eidher - Nov 10 '20 - - Dev Community

Spring Boot supports the following embedded servlet containers:

  • Tomcat
  • Jetty
  • Undertow

You can use Maven, Gradle, or Ant/Ivy as build tools to generate the jar file. However, you may need to use your own server as WebLogic, Wildfly, JBoss, etc. In that case, you would need to generate a WAR file of your Spring Boot project. To do that you have to do the next changes:

  • Change artifact type to WAR
  • Extend SpringBootServletInitializer
  • Override the configure method
@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
}
Enter fullscreen mode Exit fullscreen mode

mvn package will create a hybrid and a traditional (.original) WAR. The traditional WAR is produced without the embedded tomcat. So, you can use the .war.original file in your application server.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player