IDEA new create Spring Boot Project,
run main class: SpringbootJdbcApplication Application应用直接退出
2018-02-05 10:25:19.795 INFO 93703 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-02-05 10:25:19.814 INFO 93703 --- [ main] c.e.s.SpringbootJdbcApplication : Started SpringbootJdbcApplication in 2.272 seconds (JVM running for 3.018)
2018-02-05 10:25:19.815 INFO 93703 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@3bd94634: startup date [Mon Feb 05 10:25:18 CST 2018]; root of context hierarchy
2018-02-05 10:25:19.817 INFO 93703 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
原因在于Application 运行时缺少一个容器container,
项目中为了打成war 包,引入了 依赖,该依赖默认scope 为provided,编译直接运行后,无法确定一个容器,项目无法启动。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
Solution: 把该依赖注释掉; 或者 把<scope>provided</scope>改为 <scope>compile</scope>
maven dependency scope: compile\test \runtime\provided\system
reference: http://blog.csdn.net/kimylrong/article/details/50353161