-
Notifications
You must be signed in to change notification settings - Fork 41.2k
spring.jackson.date-format configuration does not affect serialization of Date #6642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Your web configuration class is annotated with You should remove the |
Taking complete control means Boot no longer configures Spring MVC's Jackson-based HTTP message converter. spring-projects/spring-boot#6642
I have the same problem when I config jackson with The root cause is here http://stackoverflow.com/questions/32654854/the-spring-jackson-serialization-inclusion-environment-setting-does-not-seem-to |
hatavan's solution is easy and directly, but it's not the root cause, though add spring-boot-starter-data-rest in your classpath solve the problem; the root cause is that when spring boot init default MappingJackson2HttpMessageConverter it does'n use the Jackson2ObjectMapperBuilder instance which created by JacksonAutoConfiguration, this is because Jackson2ObjectMapperBuilderCustomizerConfiguration has an order(0) priority. |
@zhaozhi406 The root cause in this issue was the use of The order on the customiser is 0 to allow user-provided customisers to go before and after it. It will have no effect on what does and does not use the auto-configured ObjectMapper. If you have found a situation where what you have described on Stack Overflow is necessary, please open a new issue with a small sample that reproduces the problem. What you are doing should not be necessary so there may be a bug that we should fix. |
I'm having an issue similar to a one described by @csavory in #2225 - if I add a WebConfig that extends
WebMvcConfigurerAdapter
then my date format specified for jackson in application.properties is not taking effect:I'm using boot spring boot 1.4.0. Example of failing test case is at https://github.com/pavelfomin/spring-boot-rest-example (
branch feature/actuator-only
):The
build.time
field is expected to be formatted according tospring.jackson.date-format
. If I comment out@Configuration
in WebConfiguration which extendsWebMvcConfigurerAdapter
then the test case passes.How to reproduce:
git clone --branch feature/actuator-only https://github.com/pavelfomin/spring-boot-rest-example.git
mvn clean test
The test run results in the following error:
@Configuration
in WebConfigurationmvn clean test
The text was updated successfully, but these errors were encountered: