当前位置:   article > 正文

docker中运行springboot服务jar包服务器不是北京时间问题_docker 运行jar 时区

docker 运行jar 时区

 1.在配置文件中配置数据库url地址加上下面的参数serverTimezone=GMT%2B8

保持数据库时间为北京时间 

  1. spring.datasource.url = jdbc:mysql://192.168.0.173:3306/guard?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&rewriteBatchedStatements=true&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2B8
  2. spring.datasource.username = username
  3. spring.datasource.password = password
  4. spring.datasource.driver-class-name=com.mysql.jdbc.Driver

2.在pojo中的时间类型字段注解上不需要再加timezone = "GMT+8"

  1. /**
  2. * @description:基类
  3. * @author :liuf
  4. * @since :2020/7/21 16:57
  5. */
  6. public class BasicEntity implements Serializable {
  7. private static final long serialVersionUID = -6150348308354729953L;
  8. /**
  9. * 创建人
  10. */
  11. private String creatorId;
  12. /**
  13. * 创建时间
  14. */
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/863339
推荐阅读
相关标签
  

闽ICP备14008679号