1. 程式人生 > 實用技巧 >springboot啟動報錯:Cannot determine embedded database driver class for database type NONE

springboot啟動報錯:Cannot determine embedded database driver class for database type NONE

一.報錯資訊

2020-08-17 10:28:21.731  INFO 9208 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2020-08-17 10:28:21.747  INFO 9208 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2020-08-17 10:28:21.753 ERROR 9208 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** 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).

從意思分析,就是因為我沒有配置資料庫的連線唄,但是我又不需要連線資料庫,所以

二.解決辦法

需要在啟動類的@EnableAutoConfiguration或@SpringBootApplication中新增exclude = {DataSourceAutoConfiguration.class},排除此類的autoconfig。啟動以後就可以正常執行。排除資料庫的自動啟動

package com.web.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) public class ApplicationStart { public static void main(String[] args) { SpringApplication.run(ApplicationStart.class, args); } }