在使用yml文件配置mysql数据库的连接信息时,出现以下的错误
出现这种问题的原因是由于版本问题:
显示新版本的数据库连接程序需要指定UTC时区,改正方法将配置文件中的“url”后面加上指定的时区
这里给出propertie问件和yml文件配置的修改:
原properties文件配置:
jdbc.driverClass = com.mysql.jdbc.Driver
jdbc.url = jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8
jdbc.username = root
jdbc.password = 123456
更改后properties文件配置
jdbc.driverClass = com.mysql.jdbc.Driver
jdbc.url = jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT
jdbc.username = root
jdbc.password = 123456
如果使用yml文件配置:
原yml文件配置:
spring:
datasource:
username: root
password: 123456
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8
driver-class-name: com.mysql.jdbc.Driver
修改后的yml配置文件:
spring:
datasource:
username: root
password: 123456
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT
driver-class-name: com.mysql.jdbc.Driver