2018-10-14 18:53:06.591 INFO 10080 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-10-14 18:53:07.563 INFO 10080 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-10-14 18:53:07.564 INFO 10080 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-10-14 18:53:07.567 INFO 10080 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-10-14 18:53:07.604 INFO 10080 --- [ main] com.example.jpa.demo.DemoApplication : Started DemoApplication in 10.065 seconds (JVM running for 17.481)
2018-10-14 18:53:07.605 INFO 10080 --- [ Thread-23] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@501edcf1: startup date [Sun Oct 14 18:52:59 CST 2018]; root of context hierarchy
2018-10-14 18:53:07.608 INFO 10080 --- [ Thread-23] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2018-10-14 18:53:07.609 INFO 10080 --- [ Thread-23] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
2018-10-14 18:53:07.609 INFO 10080 --- [ Thread-23] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2018-10-14 18:53:07.610 INFO 10080 --- [ Thread-23] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2018-10-14 18:53:07.629 INFO 10080 --- [ Thread-23] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
从上面的运行信息可以看出,Appication已经运行了,却突然又关闭了,所以根据我的分析,很可能就加载的容器产生的冲突,
解决方法为:将pom文件下的这个
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
改为:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
到此为止就可以完美运行了,更多SpringBoot入门踩坑解决方法请关注,我带你走出各种坑。