今天遇到如题的问题,各种搜索关键字都找不到我想要的,基本搜索到的都是mysql的jdbcurl后面加一个配置,我用的是sqlserver跟这个没有关系。
还有提到applicationContext里加上这句话的,我也试了没用
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
期间还怀疑了logback版本、windows时间问题
------------------------------------------------------------------------------------------------------------
最后发现是logback的pattern导致的,官网有解释https://logback.qos.ch/manual/layouts.html
我是错在HH:mm:ss.SSS和HH:mm:ss,SSS。
我直接搜索yyyy,搜到第一段有了含逗号的那个patern就直接复制粘贴拿来用了,后面发现是logback配置文件问题一步一步细分发现是patern去查了官网才发现这个问题。
官方说: Given that the comma ',' character is interpreted as the parameter separator, the pattern HH:mm:ss,SSS
will be interpreted as the pattern HM:mm:ss
and the timezone SSS
. If you wish to include a comma in your date pattern, then simply enclose the pattern between quotes. For example, %date{"HH:mm:ss,SSS"}.
在使用逗号时,会默认使用时区设置,坑了我一个下午。。。啊大家引以为戒,看文章仔细点