Spring boot\'s preferred deployment method is via a executable jar file which contains tomcat inside.
It is started with a simple java -jar myapp.jar.>
My Spring boot application has two initializers. One for development and another for production. For development, I use the main method like this:
@SpringBootApplication
public class MyAppInitializer {
public static void main(String[] args) {
SpringApplication.run(MyAppInitializer .class, args);
}
}
My Initializer for production environment extends the SpringBootServletInitializer and looks like this:
@SpringBootApplication
public class MyAppInitializerServlet extends SpringBootServletInitializer{
private static final Logger log = Logger
.getLogger(SpringBootServletInitializer.class);
@Override
protected SpringApplicationBuilder configure(
SpringApplicationBuilder builder) {
log.trace("Initializing the application");
return builder.sources(MyAppInitializerServlet .class);
}
}
I use gradle and my build.gradle file applies 'WAR' plugin. When I run it in the development environment, I use bootrun task. Where as when I want to deploy it to production, I use assemble task to generate the WAR and deploy.
I can run like a normal spring application in production without discounting the advantages provided by the inbuilt tomcat while developing. Hope this helps.