SpringBoot程序启动时出现错误:
***************************
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).
解决方法:
①在主启动类中排除数据源的自动配置依赖
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
②将pom文件中的mybatis依赖去掉
<!--
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
-->
③在application.yml文件(或application.xml
【将下面的yml格式转换成xml格式即可 在线转换器:https://www.toyaml.com/index.html】)
中添加数据源的相关配置
spring:
application:
name: study-cloud-test
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: org.gjt.mm.mysql.Driver
url: jdbc:mysql://localhost:3306/cloudDB
username: root
password: 123456
dbcp2:
min-idle: 5 # 数据库连接池的最小维持连接数
initial-size: 5 #初始化连接数
max-total: 5 #最大连接数
max-wait-millis: 200 # 等待连接获取的最大超时时间