- 前言
- 一、遇到问题
- 二、原因
- 三、拓展
在学习Spring Boot 2.x基础教程:使用国产数据库连接池Druid
SpringBoot2版本
一、遇到问题org.springframework.boot spring-boot-starter-parent 2.6.7
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSource': Unsatisfied dependency expressed through field 'basicProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseType
Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType二、原因
未引入这个依赖
三、拓展org.springframework.boot spring-boot-starter-jdbc
若SpringBoot2项目需要连接数据库mysql,使用数据库连接池druid则必须添加以下依赖
mysql
mysql-connector-java
org.springframework.boot
spring-boot-starter-jdbc
com.alibaba
druid-spring-boot-starter
1.1.21
需要查看Druid监控则可以添加下面依赖
org.springframework.boot
spring-boot-starter-actuator
具体相关信息,都可以参考这边文章Spring Boot 2.x基础教程:使用国产数据库连接池Druid



