Skip to main content

Posts

Create WAR file in Spring Boot

This is just a three step simple procedure to package your application into war. Extending Main Class First, we extend our main class to SpringBootServletInitializer. This tells spring that your main class will be the entry point to initialize your project in server. ? 1 2 3 4 5 6 7 @SpringBootApplication public class Application extends SpringBootServletInitializer{        public static void main(String[] args) {          SpringApplication.run(Application. class , args);      } } Overriding configure method Next, we overload the configure method of SpringBootServletInitializer. We tell spring to build the sources from our Main class. Your final Main class should look like this: ? 1 2 3 4 5 6 7 8 9 10 11 12 @SpringBootApplication public class Application extends SpringBootServletInitializer{        public static void main(String[] args) {          SpringApplication.run(Application. class , args);      }        @Override      protected SpringApplicationBuilder configure(Spr