JavaJaxRS.libraries.jersey3.jacksonJsonProvider.mustache Maven / Gradle / Ivy
package {{apiPackage}};
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.*;
import com.fasterxml.jackson.jakarta.rs.json.JacksonXmlBindJsonProvider;
import {{javaxPackage}}.ws.rs.Produces;
import {{javaxPackage}}.ws.rs.core.MediaType;
import {{javaxPackage}}.ws.rs.ext.Provider;
@Provider
@Produces({MediaType.APPLICATION_JSON})
public class JacksonJsonProvider extends JacksonXmlBindJsonProvider {
public JacksonJsonProvider() {
ObjectMapper objectMapper = new ObjectMapper()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.registerModule(new JavaTimeModule())
.setDateFormat(new RFC3339DateFormat());
setMapper(objectMapper);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy