SpringBoot2.1.3、MySQL8.0时区一致

@JsonFiled

查询结果与数据库相差8个小时

解决方式一:

jdbc:mysql://192.168.0.250:3308/erp_61?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=UTC

-->jdbc:mysql://192.168.0.250:3308/erp_61?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8

解决方式二:

....

public class ModuleApplication {
    @PostConstruct
    void started() {
       TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    }
    public static void main(String[] args) {
        SpringApplication.run(ModuleApplication.class, args);
    }
}
 

你可能感兴趣的:(偶遇问题-处理简单)