SpringBoot Closing org.springframework.context.annotation.AnnotationConfigApplicationContext 錯誤解決
阿新 • • 發佈:2018-12-15
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.spring
[email protected]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入門踩坑解決方法請關注,我帶你走出各種坑。