页面效果:
数据库:
原因分析:使用UTC/GMT会有8小时的时差(中国快全球标准8小时,比如:全球标准当前是上午1点,中国时间则为上午9点),
UTC:Universal Coordinated Time
GMT:格林威治标准时间(Greenwich Mean Time)
我们可以认为格林威治时间就是世界协调时间(GMT=UTC),
UTC + 8小时 = 北京时间
解决办法:可设置为北京时间东八区GMT%2B8 或者上海时间Asia/Shanghai。
原来的时区是这样的:
spring.datasource.url=jdbc:mysql://localhost:63306/mtyh ?characterEncoding=utf8 &useoldAliasMetadataBehavior=true &serverTimezone=GMT &useSSL=false
现在改成:
spring.datasource.url=jdbc:mysql://localhost:63306/mtyh ?characterEncoding=utf8 &useoldAliasMetadataBehavior=true &serverTimezone=GMT%2B8 &useSSL=false
或者
spring.datasource.url=jdbc:mysql://localhost:63306/mtyh ?characterEncoding=utf8 &useoldAliasMetadataBehavior=true &serverTimezone=Asia/Shanghai &useSSL=false