qq_慕用9579179
2020-12-25 22:53
jdbc.driver=com.mysql.cj.jdbc.Driver
代码替换完了之后还要在url中添加时区,否则还会报can't find application context错误
jdbc.url=jdbc:mysql://localhost:3306/demo?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false
如果把jdbc依赖改了但还是报错数据库链接不上,并且mapper.xml文件中方法名没写错,其他地方都没写错,可以试一下在写DataSourceConfiguration这个类时,把Value都配成显式的,而不是用application.properties里面写好的配置
@Value("com.mysql.cj.jdbc.Driver") private String jdbcDriver; @Value("jdbc:mysql://localhost:3306/one_text?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false") private String jdbcUrl; @Value("root") private String jdbcUsername; @Value("123456") private String jdbcPassword;
附上当时解决问题参考的网页:
https://programmerah.com/how-to-solve-jdbc-connection-error-in-spring-mvc-integration-38071/
lz谢谢!!
改了之后还是会有报错Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
原因:mysql 5.x 与 mysql8.x 的区别
SpringBoot+MyBatis搭建迷你小程序
91500 学习 · 621 问题
相似问题