Java – how do I prevent the spring boot daemon / server application from shutting down immediately?
My spring boot application is not a web server, but it is a server using a custom protocol (using camel in this case)
However, after starting, the spring start will stop immediately (elegant) How to prevent this?
I want the application to stop if Ctrl C or programming
@CompileStatic @Configuration class CamelConfig { @Bean CamelContextfactorybean camelContext() { final camelContextFactory = new CamelContextfactorybean() camelContextFactory.id = 'camelContext' camelContextFactory } }
Solution
From Apache camel 2.17, there is a cleaner answer quote http://camel.apache.org/spring-boot.html : @H_ 502_ 12@
To keep the main thread blocked so that Camel stays up,either include the spring-boot-starter-web dependency,or add camel. springboot. main-run-controller=true to your application. properties or application. yml file.
You also need the following dependencies:
Groupid gt of < dependency > < & gt; org. apache. Groupid gt of camel < / & gt< Artifactid's > camel spring guided start < / artifactid's > < version > 2.17 0 < / version > < / dependency >
Explicitly replace < version > 2.17 0 < / version > or use BOM to import dependency management information for consistency