DEV Community

eidher
eidher

Posted on • Edited on

3

Spring Boot for war

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.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (1)

Collapse
 
kirantrathod profile image
KIRAN T RATHOD

What if I want to create war of spring boot and angular in weblogic.

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️