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