springboot使用JPA數據訪問啓動報錯:Cannot determine embedded database driver class for database type NONE

springboot使用JPA數據訪問啓動報錯:Cannot determine embedded database driver class for database type NONE

maven工程: SpringBoot1.5 +Web+JPA+MYSQL+JDBC

報錯信息如下:

***************************
APPLICATION FAILED TO START
***************************

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

問題原因:
 產生這個異常是因爲 SpringBoot 啓動時會自動注入數據源和配置 jpa

解決方案:
在啓動類的@SpringBootApplication註解加入以下代碼:

@SpringBootApplication(exclude=
        {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
@ComponentScan(basePackages = {"com.lvshuy.addresslist.repository"})
public class AddresslistApplication {

    public static void main(String[] args) {
        SpringApplication.run(AddresslistApplication.class, args);
    }
}

參考鏈接:
https://segmentfault.com/a/1190000015413813?utm_source=tag-newest

相關問題:
【springboot使用jpa啓動報錯consider defining a bean of type ‘..**Repository’ in your configuration.】

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章