support iso dates
This commit is contained in:
parent
5047d3b154
commit
2dee73ce1f
|
@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import eu.eudat.data.BaseEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -14,11 +15,14 @@ import org.springframework.boot.autoconfigure.domain.EntityScan;
|
|||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {
|
||||
"eu.eudat",
|
||||
"eu.eudat.depositinterface",
|
||||
|
@ -33,24 +37,9 @@ public class EuDatApplication extends SpringBootServletInitializer {
|
|||
|
||||
@Bean
|
||||
@Primary
|
||||
public ObjectMapper primaryObjectMapper() {
|
||||
return JsonMapper.builder().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
.configure(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS, true)
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.addModule(new JavaTimeModule()).build();
|
||||
public ObjectMapper primaryObjectMapper(Jackson2ObjectMapperBuilder builder) {
|
||||
return builder.modulesToInstall(new JavaTimeModule()).build();
|
||||
}
|
||||
// @Bean
|
||||
// public Jackson2ObjectMapperBuilder objectMapperBuilder() {
|
||||
// return new Jackson2ObjectMapperBuilder() {
|
||||
//
|
||||
// @Override
|
||||
// public void configure(ObjectMapper objectMapper) {
|
||||
// objectMapper.registerModule(new JavaTimeModule());
|
||||
// super.configure(objectMapper);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package eu.eudat.configurations;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import eu.eudat.interceptors.UserInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
spring:
|
||||
jackson:
|
||||
default-property-inclusion: non_null
|
||||
deserialization:
|
||||
fail-on-unknown-properties: false
|
||||
serialization:
|
||||
write-dates-as-timestamps: false
|
||||
config:
|
||||
import: optional:classpath:config/app.env[.properties], optional:file:../config/app.env[.properties],
|
||||
optional:classpath:config/db.yml[.yml], optional:classpath:config/db-${spring.profiles.active}.yml[.yml], optional:file:../config/db-${spring.profiles.active}.yml[.yml],
|
||||
|
|
Loading…
Reference in New Issue