SpringBoot2接口返回时间和MySQL中显示的时间不一致
user_id user_name introduce mobilephone email birthday gender
gavin 盖文 大学教授 13940981276 [email protected] 2019-10-07 男
检索结果:
{
"userId": "gavin",
"userName": "盖文",
"introduce": "大学教授",
"mobilephone": "13940981276",
"email": "[email protected]",
"birthday": "2019-10-06T16:00:00.000+0000",
"gender": "男"
}
解决对策:
修改JDBC链接,添加参数serverTimezone=UTC。
spring.datasource.url=jdbc:mysql://119.3.155.111:3306/ss_mng?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC