| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.config;
|
1 |
package com.spice.profitmandi.web.config;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.time.LocalDateTime;
|
| - |
|
4 |
import java.time.chrono.IsoChronology;
|
| - |
|
5 |
import java.time.format.DateTimeFormatter;
|
| - |
|
6 |
import java.time.format.DateTimeFormatterBuilder;
|
| - |
|
7 |
import java.time.format.ResolverStyle;
|
| 3 |
import java.util.List;
|
8 |
import java.util.List;
|
| 4 |
|
9 |
|
| 5 |
import org.springframework.beans.factory.annotation.Autowired;
|
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
11 |
import org.springframework.context.annotation.Bean;
|
| 6 |
import org.springframework.context.annotation.ComponentScan;
|
12 |
import org.springframework.context.annotation.ComponentScan;
|
| 7 |
import org.springframework.context.annotation.Configuration;
|
13 |
import org.springframework.context.annotation.Configuration;
|
| 8 |
import org.springframework.format.FormatterRegistry;
|
14 |
import org.springframework.format.FormatterRegistry;
|
| 9 |
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
|
15 |
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
|
| 10 |
import org.springframework.http.converter.HttpMessageConverter;
|
16 |
import org.springframework.http.converter.HttpMessageConverter;
|
| 11 |
import org.springframework.http.converter.ResourceHttpMessageConverter;
|
- |
|
| 12 |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
17 |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
| 13 |
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
18 |
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
| 14 |
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
19 |
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
| 15 |
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
20 |
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
| 16 |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
21 |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
| 17 |
|
22 |
|
| 18 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
23 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 19 |
import com.fasterxml.jackson.databind.SerializationFeature;
|
- |
|
| 20 |
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
24 |
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
| 21 |
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
25 |
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
| - |
|
26 |
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
| - |
|
27 |
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
| 22 |
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
28 |
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
| 23 |
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
|
29 |
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
|
| 24 |
import com.spice.profitmandi.web.interceptor.RoleInterceptor;
|
30 |
import com.spice.profitmandi.web.interceptor.RoleInterceptor;
|
| 25 |
|
31 |
|
| 26 |
@EnableWebMvc
|
32 |
@EnableWebMvc
|
| Line 60... |
Line 66... |
| 60 |
@Override
|
66 |
@Override
|
| 61 |
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
|
67 |
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
|
| 62 |
converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
|
68 |
converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
|
| 63 |
}
|
69 |
}
|
| 64 |
|
70 |
|
| - |
|
71 |
@Bean
|
| 65 |
private ObjectMapper objectMapper() {
|
72 |
public ObjectMapper objectMapper() {
|
| - |
|
73 |
DateTimeFormatter df = new DateTimeFormatterBuilder()
|
| - |
|
74 |
.parseCaseInsensitive()
|
| - |
|
75 |
.append(DateTimeFormatter.ISO_LOCAL_DATE)
|
| - |
|
76 |
.optionalStart()
|
| - |
|
77 |
.appendLiteral('T')
|
| - |
|
78 |
.optionalEnd()
|
| - |
|
79 |
.appendLiteral(' ')
|
| - |
|
80 |
.append(DateTimeFormatter.ISO_LOCAL_TIME)
|
| - |
|
81 |
.toFormatter();
|
| - |
|
82 |
DateTimeFormatter sf = new DateTimeFormatterBuilder()
|
| - |
|
83 |
.parseCaseInsensitive()
|
| - |
|
84 |
.append(DateTimeFormatter.ISO_LOCAL_DATE)
|
| - |
|
85 |
.appendLiteral('T')
|
| - |
|
86 |
.append(DateTimeFormatter.ISO_LOCAL_TIME)
|
| - |
|
87 |
.toFormatter();
|
| - |
|
88 |
LocalDateTimeSerializer serializer = new LocalDateTimeSerializer(sf);
|
| - |
|
89 |
LocalDateTimeDeserializer deserializer = new LocalDateTimeDeserializer(df);
|
| - |
|
90 |
JavaTimeModule jtm = new JavaTimeModule();
|
| - |
|
91 |
jtm.addSerializer(LocalDateTime.class, serializer);
|
| - |
|
92 |
jtm.addDeserializer(LocalDateTime.class, deserializer);
|
| 66 |
ObjectMapper mapper = new ObjectMapper()
|
93 |
ObjectMapper mapper = new ObjectMapper()
|
| 67 |
.registerModule(new ParameterNamesModule())
|
94 |
.registerModule(new ParameterNamesModule())
|
| 68 |
.registerModule(new Jdk8Module())
|
95 |
.registerModule(new Jdk8Module())
|
| 69 |
.registerModule(new JavaTimeModule()); // new module, NOT JSR310Module
|
96 |
.registerModule(jtm); // new module, NOT JSR310Module
|
| 70 |
return mapper;
|
97 |
return mapper;
|
| 71 |
}
|
98 |
}
|
| 72 |
|
99 |
|
| 73 |
}
|
100 |
}
|