springboot整合mybatis遇到的问题

  • 问题

    启动后出现数据库问题
    bug提示 java.sql.SQLException: The server time zone value ‘�й���׼ʱ��’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zo

    解决方式
    mysql-connector-java这个jar包是最新的时候
    在application.properties配置文件中配置datasource.url时不能简单的这样配:
    spring.datasource.url=jdbc:mysql://localhost:3306/chat
    需要加上一些必要的后缀信息(改成下面的配置就可以了):
    spring.datasource.url=jdbc:mysql://localhost:3306/chat?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

  • 问题 插入数据的时候出现bug
    mybatis链接数据库mysql8.0Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL synta

    解决方式
    修改了其中的某个字段名“signal”,居然奇迹般的就不报错了,能正常的运行了,于是突然意识到,这个错误我使用了某个MYSQL的关键字导致的,于是跑到官网去看,真的被我看到使用了此关键字。

  • 问题 配置数据源application.properties出现的问题
    bug提示 Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver’. The driver is
    automatically registered via the SPI and manual loading of the driver
    class is generally unnecessary.

    解决方式
    mysql8.0以上版本的数据库 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    mysql8.0以下 spring.datasource.driver-class-name=com.mysql.jdbc.Driver

  • 问题 配置文件出现spring.datasource.driver-class-name=com.mysql.jdbc.Driver中 mysql.jdbc这几个发红报错**
    解决方式
    其实这个问题是由于MySQL 这个jar 包依赖类型默认是runtime , 也就是说只有运行时生效,所以虽然这里报错,但是不影响你代码运行。 将runtime 修改为Compile 即可
    1 选中项目—> 右键-----> Open Module Settings 在这里插入图片描述
    2 Modules ------> *****App -------> Dependencies
    在这里插入图片描述
    3 将runtime 修改为Compile即可
    在这里插入图片描述

问题: IntelliJ Idea解决Could not autowire. No beans of ‘xxxx’ typefound的错误提示
在这里插入图片描述

解决方案
降低Autowired检测的级别,将Severity的级别由之前的error改成warning或其它可以忽略的级别。
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值