寫了個簡單的Springboot工程,啟動時始終會報錯:
“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在啟動時默認會注入數據源,但是系統中又找不到數據庫的配置,因此報錯。
解決:
如果項目確實不需要連接數據庫,請在啟動類中添加注解
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

問題解決。
