SpringBoot整合Druid遇到org.springframework.jdbc.CannotGetJdbcConnectionException错误

org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: url not set

在这里插入图片描述
最近练习的时候,遇到了这个问题,在解决问题后,还是连续遇到了两次,就为粗心的我记上一笔。

在确认自己的配置文件url全部都没错的时候还是报错,那就是在DruidConfig中没有绑定全局配置文件。
在这里插入图片描述

@ConfigurationProperties(prefix = “spring.datasource”):作用就是将全局配置文件中前缀为 spring.datasource的属性值注入到 com.alibaba.druid.pool.DruidDataSource 的同名参数中

在次启动测试:问题解决,正常运行
在这里插入图片描述愿世上永无bug

猜你喜欢

转载自blog.csdn.net/PINKMIAO/article/details/108380437