SpringBoot:Jpa获取数据库数据,进行单元测试的时候出现错误:java.lang.IllegalStateException: Failed to load ApplicationContext
极大的可能是你配置文件连接数据库的配置写错了,好好看一下:
before:
#连接数据库
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/book?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
data-username: root
data-password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
after:
#连接数据库
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/book?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
data-username和username是不一样的!!!!
一定要睁大眼睛好好看