Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
报错信息如下
在这里插入图片描述
这时要检查application.properties配置文件有没有问题!
在这里插入图片描述
在这里插入图片描述
检查了,没问题,再检查@Value注解
在这里插入图片描述
也没有问题。。。
按照网上帖子里描述的类似问题,什么在url后面加useSSL=false或者统一时区serverTimezone=GMT。
都没用

在一次次摸索中,我把配置改成了这种形式:

spring.datasource.url=jdbc:mysql://localhost:3306/demo?characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false
spring.datasource.username=root
spring.datasource.password=lqb100118
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

在这里插入图片描述
再相应修改@Value注解
在这里插入图片描述
然后惊喜的发现,绿了。
在这里插入图片描述

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐