mysql5.6连接遇到的问题

来源:互联网 发布:郑和 知乎 编辑:程序博客网 时间:2024/05/18 20:12

maven项目 springcloud的demospring-mybatis整合 mysql数据库5.6


1.   Caused by: java.lang.IllegalStateException: Cannot load driver class: org.gjt.mm.mysql.Driver

改为   com.mysql.jdbc.Driver后,出现如下提示:

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

最终改为: com.mysql.cj.jdbc.Driver



2.  Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: 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 zone value if you want to utilize time zone support.

在数据库连接的url后加上  ?serverTimezone=UTC


示例: application.yml中关于数据源配置

spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/db8001?serverTimezone=UTC
    username: root
    password: 123456

原创粉丝点击