Created
February 5, 2016 20:18
-
-
Save alexandreaquiles/b00ca3fdb35e45f0c53d to your computer and use it in GitHub Desktop.
Configurações necessárias para (de)serializar classes do pacote java.time com o Jackson 2.x em uma API implementada com JAX-RS 2. Testado com o Wildfly 8.2.0.Final.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Provider | |
public class JacksonJavaTimeConfiguration implements ContextResolver<ObjectMapper> { | |
private final ObjectMapper mapper; | |
public JacksonJavaTimeConfiguration() { | |
mapper = new ObjectMapper(); | |
mapper.registerModule(new JSR310Module()); | |
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); | |
} | |
@Override | |
public ObjectMapper getContext(Class<?> type) { | |
return mapper; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>com.fasterxml.jackson.datatype</groupId> | |
<artifactId>jackson-datatype-jsr310</artifactId> | |
<version>2.4.1</version> | |
</dependency> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment