【SpringBoot】啓動報錯Cannot determine embedded database driver...

遇到問題

  今天在 SpringBoot 項目中引入 jpa 的 jar 包以後,啓動就報錯:Cannot determine embedded database driver class for database type NONE
  如下是 jpa 的 maven 地址:java

<!-- jpa -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

  啓動報錯以下圖:
spring

問題緣由

  產生這個異常發現是 SpringBoot 啓動時會自動注入數據源和配置 jpamaven

解決方案

  在啓動類中加入如下代碼:spring-boot

@SpringBootApplication(exclude=
{DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})


  從新啓動項目便可。spa

相關文章
相關標籤/搜索