1. 程式人生 > >Spring Boot 報錯:Error creating bean with name 'entityManagerFactory' defined in class path resource

Spring Boot 報錯:Error creating bean with name 'entityManagerFactory' defined in class path resource

fine 依賴 debug isp jpa java idt .com ima

spring boot 寫一個web項目,在使用spring-data-jpa的時候,啟動報如下錯誤:

Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug‘ enabled.
2018-04-02 17:00:47.076 ERROR 4648 --- [ main] o.s.boot.SpringApplication : Application startup failed

解決方式:加入依賴既可

    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
      <version>5.0.3.Final</version>
    </dependency>

另外,有看到資料說,在mainApplication中,加如下註解也可以解決:

  @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

啟動的確不報錯了,但是此時,自動創建表功能並未實現,建議用第一種方式。

技術分享圖片

Spring Boot 報錯:Error creating bean with name 'entityManagerFactory' defined in class path resource