Merge remote-tracking branch 'origin/master' into 2.3.0

This commit is contained in:
wing328
2017-04-25 23:34:45 +08:00
38 changed files with 205 additions and 76 deletions

View File

@@ -9,6 +9,7 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
@@ -66,21 +67,23 @@ public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
}
}
@Bean
public Jackson2ObjectMapperBuilder builder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder()
.indentOutput(true)
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.dateFormat(new RFC3339DateFormat());
return builder;
}
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.dateFormat(new RFC3339DateFormat())
.build();
{{#threetenbp}}
ThreeTenModule module = new ThreeTenModule();
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
objectMapper.registerModule(module);
{{/threetenbp}}
converters.add(new MappingJackson2HttpMessageConverter(objectMapper));
converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
super.configureMessageConverters(converters);
}
@Bean
public ObjectMapper objectMapper(){
return builder().build();
}
}