在application.properties增加
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.joda-date-time-format=yyyy-MM-dd HH:mm:ss
但是并没有生效,返回的时间依然是long型的时间戳。并且我是想把这里的dataFormat改成动态的,但是加了以后一直在报错。我先把我的代码贴一下,看看哪位朋友可以帮忙解决。
pom.xml
4.0.0
com.hiwi
manager
jar
0.0.1-SNAPSHOT
UTF-8
1.8
com.hiwi.AppStartUp
org.springframework.boot
spring-boot-starter-parent
1.3.7.RELEASE
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-logging
org.springframework.boot
spring-boot-starter-log4j
org.springframework.boot
spring-boot-starter-tomcat
org.springframework.boot
spring-boot-starter-aop
org.springframework.boot
spring-boot-starter-redis
org.springframework.boot
spring-boot-starter-jdbc
com.alibaba
druid
1.0.25
mysql
mysql-connector-java
org.apache.commons
commons-lang3
3.4
commons-fileupload
commons-fileupload
1.3.1
org.apache.commons
commons-email
1.4
org.codehaus.jackson
jackson-mapper-asl
1.9.13
dom4j
dom4j
1.6.1
net.sf.ehcache
ehcache-core
2.6.11
com.alibaba
fastjson
1.2.7
org.apache.httpcomponents
httpclient
jexcelapi
jxl
2.6
org.apache.poi
poi-ooxml
3.13
javax.mail
mail
1.4.7
org.quartz-scheduler
quartz
2.2.1
org.freemarker
freemarker
org.jsoup
jsoup
1.9.2
commons-dbutils
commons-dbutils
1.6
${project.groupId}.${project.artifactId}
compile
org.springframework.boot
spring-boot-maven-plugin
application.properties
spring.mvc.view.prefix=/html/page
spring.mvc.view.suffix=.jsp
spring.mvc.media-types.*=text/html;application/json
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.joda-date-time-format=yyyy-MM-dd HH:mm:ss
#multipart
multipart.enabled=true
#文件上传大小,单位M
multipart.max-file-size=10
multipart.max-request-size=10
额外的xml配置文件
text/html;charset=UTF-8
application/json;charset=UTF-8
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
customObjectMapper这个对象是怎么来的?如果是自己创建的那直接通过ObjectMapper设置,反之你使用配置的方式应该使用spring-boot配置创建方式。已经解决问题了。与spring-boot启动类的注解有关
解决了,怎么不写清楚呀,我也遇到这个问题了,好烦人呀