eclipse中动态web连接mysql遇到的问题
问题一:配置文件路径不对问题
首先要创建数据库的配置属性文件jdbc.properties,并且要和配置类的包放在相同的目录下,否则@PropertySource(value = {"classpath:jdbc.properties"},ignoreResourceNotFound = true)中找不到配置属性文件。

问题二:配置文件版本不对应问题
虽然我的版本和书上的例题版本都是5.*,提醒以后的~~
com.mysql.jdbc.Driver 是 mysql-connector-java 5中,基本格式如下:(本人选)
jdbc.driverClassName = com.mysql.jdbc.Driver
jdbc.url = jdbc:mysql://localhost:3306/springtest?useUnicode=true&characterEncoding = utf8&useSSL=false
jdbc.username = root
jdbc.password =
com.mysql.cj.jdbc.Driver 是 mysql-connector-java 6以及以上中,基本格式如下:
jdbc.driverClassName=com.mysql.cj.jdbc.Driver
jdbc.url = jdbc:mysql://localhost:3306/springtest?serverTimezone=UTC&?jdbc.useUnicode = true&characterEncoding=utf8&useSSL=false
jdbc.username = root
jdbc.password =
问题三:数据库主键不自增问题
错误提示为Column 'uid' cannot be null
解决方法:只需要给uid主键设置为自动增长即可。
问题四:常用get和set方法缺少问题
书本例题省略set和get方法,如果不写的话,就会导致查出的数据全为空。

问题五:声明式事物遇到的问题
项目配置多数据源导致的 问题:No qualifying bean of type 'org.springframework.transaction.TransactionManager' available
参考一下博主即可解决,亲测有效。
->
(76条消息) springboot事务回滚报错No qualifying bean of type ‘org.springframework.transaction.TransactionManager‘ avai_仗剑天涯777i的博客-CSDN博客
<-

浙公网安备 33010602011771号