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.】