使用JdbcTemplate出现create connection SQLException, url: jdbc:mysql://localhost:3306/spring, errorCode 1045, state 28000

发布时间 2023-06-28 08:06:40作者: XLouis

原因时你的properties资源文件中命名和spring关键字冲突

username=root
password=root
url=jdbc:mysql://localhost:3306/spring
driver=com.mysql.cj.jdbc.Driver

换成下面的方法即可解决

jdbc.username=root
jdbc.password=root
jdbc.url=jdbc:mysql://localhost:3306/spring
jdbc.driver=com.mysql.cj.jdbc.Driver