项目场景:
接了个新项目,死活跑不起来,一直报
+***************************+
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).
问题描述:
原因分析:
- 数据源的问题
-
系统是想要避免自动加载数据库,但是系统本身没有配置数据源,
-
系统本身配置了数据源,但是启动时没有设置不自动加载数据库
-
解决方案:
- 第一种:
问题复现:系统是想要避免自动加载数据库,但是系统本身没有配置数据源,
解决方法:properties文件中加上数据源:
#------------------------------ mysql ----------------------------------
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/recommenddb?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
spring.datasource.username=你连数据库的用户名
spring.datasource.password=你连数据库的密码
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
#-----------------------------------------------------------------------------------------
- 第二种:
问题复现:系统本身配置了数据源,但是启动时没有设置不自动加载数据库,
解决方法:启动类:设置不自动加载数据库
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class})
或者
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}