There are two initializers in my Spring boot application. One for development, another for production. For development, I use the main method as follows:
@SpringBootApplication public class MyAppInitializer { public static void main(String[] args) { SpringApplication.run(MyAppInitializer .class, args); } }
My desktop initializer extends 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 the WAR plugin is used in the build.gradle file. When I run it in the development environment, I use the bootrun task. Where, when I want to deploy it for production, I use the collect task to create a WAR and deploy.
I can work as a regular Spring application in production without discounting the benefits provided by the built-in cat during development. Hope this helps.
O-OF-N Apr 28 '15 at 19:52 2015-04-28 19:52
source share