Skip to main content
added 463 characters in body
Source Link
Toni
  • 5.3k
  • 3
  • 18
  • 50

JavaTimeModule should be registered explicitly:

@Configuration public class JacksonConfiguration { @Bean public ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); return mapper; } } 

For reference: jackson-modules-java8 - Registering modules

UPDATE:

The first solution should be used with jackson-datatype-jsr310 versions 2.x before 2.9. Since you added version 2.13.3, the module should be registered as shown below, according to the answer.

@Configuration public class JacksonConfiguration { @Bean public ObjectMapper objectMapper() { return JsonMapper.builder() .addModule(new JavaTimeModule()) .build(); } } 

UPDATE 2:

Starting with Jackson 2.2, Modules can be automatically discovered using the Service Provider Interface (SPI) feature. You can activate this by instructing an ObjectMapper to find and register all Modules:

// Jackson 2.10 and later ObjectMapper mapper = JsonMapper.builder() .findAndAddModules() .build(); // or, 2.x before 2.9 ObjectMapper mapper = new ObjectMapper(); mapper.findAndRegisterModules(); 

For reference: jackson-modules-java8 - Registering modules

JavaTimeModule should be registered explicitly:

@Configuration public class JacksonConfiguration { @Bean public ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); return mapper; } } 

For reference: jackson-modules-java8 - Registering modules

UPDATE:

The first solution should be used with jackson-datatype-jsr310 versions 2.x before 2.9. Since you added version 2.13.3, the module should be registered as shown below, according to the answer.

@Configuration public class JacksonConfiguration { @Bean public ObjectMapper objectMapper() { return JsonMapper.builder() .addModule(new JavaTimeModule()) .build(); } } 

JavaTimeModule should be registered explicitly:

@Configuration public class JacksonConfiguration { @Bean public ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); return mapper; } } 

UPDATE:

The first solution should be used with jackson-datatype-jsr310 versions 2.x before 2.9. Since you added version 2.13.3, the module should be registered as shown below, according to the answer.

@Configuration public class JacksonConfiguration { @Bean public ObjectMapper objectMapper() { return JsonMapper.builder() .addModule(new JavaTimeModule()) .build(); } } 

UPDATE 2:

Starting with Jackson 2.2, Modules can be automatically discovered using the Service Provider Interface (SPI) feature. You can activate this by instructing an ObjectMapper to find and register all Modules:

// Jackson 2.10 and later ObjectMapper mapper = JsonMapper.builder() .findAndAddModules() .build(); // or, 2.x before 2.9 ObjectMapper mapper = new ObjectMapper(); mapper.findAndRegisterModules(); 

For reference: jackson-modules-java8 - Registering modules

Added second solution
Source Link
Toni
  • 5.3k
  • 3
  • 18
  • 50

JavaTimeModule should be registered explicitly:

@Configuration public class JacksonConfiguration { @Bean public ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); return mapper; } } 

For reference: jackson-modules-java8 - Registering modules

UPDATE:

The first solution should be used with jackson-datatype-jsr310 versions 2.x before 2.9. Since you added version 2.13.3, the module should be registered as shown below, according to the answer.

@Configuration public class JacksonConfiguration { @Bean public ObjectMapper objectMapper() { return JsonMapper.builder() .addModule(new JavaTimeModule()) .build(); } } 

JavaTimeModule should be registered explicitly:

@Configuration public class JacksonConfiguration { @Bean public ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); return mapper; } } 

For reference: jackson-modules-java8 - Registering modules

JavaTimeModule should be registered explicitly:

@Configuration public class JacksonConfiguration { @Bean public ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); return mapper; } } 

For reference: jackson-modules-java8 - Registering modules

UPDATE:

The first solution should be used with jackson-datatype-jsr310 versions 2.x before 2.9. Since you added version 2.13.3, the module should be registered as shown below, according to the answer.

@Configuration public class JacksonConfiguration { @Bean public ObjectMapper objectMapper() { return JsonMapper.builder() .addModule(new JavaTimeModule()) .build(); } } 
added configuration class
Source Link
Toni
  • 5.3k
  • 3
  • 18
  • 50

JavaTimeModule should be registered explicitly:

@Configuration public class JacksonConfiguration { @Bean  public ObjectMapper objectMapper() {   ObjectMapper mapper = new ObjectMapper();   mapper.registerModule(new JavaTimeModule());   return mapper; } } 

For reference: jackson-modules-java8 - Registering modules

JavaTimeModule should be registered explicitly:

@Bean public ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); return mapper; } 

For reference: jackson-modules-java8 - Registering modules

JavaTimeModule should be registered explicitly:

@Configuration public class JacksonConfiguration { @Bean  public ObjectMapper objectMapper() {   ObjectMapper mapper = new ObjectMapper();   mapper.registerModule(new JavaTimeModule());   return mapper; } } 

For reference: jackson-modules-java8 - Registering modules

Source Link
Toni
  • 5.3k
  • 3
  • 18
  • 50
Loading