| Line 1... |
Line 1... |
| 1 |
package com.smartdukaan.cron.config;
|
1 |
package com.smartdukaan.cron.config;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.time.LocalDateTime;
|
| - |
|
4 |
import java.time.format.DateTimeFormatter;
|
| - |
|
5 |
import java.time.format.DateTimeFormatterBuilder;
|
| 3 |
import java.util.Properties;
|
6 |
import java.util.Properties;
|
| 4 |
|
7 |
|
| 5 |
import javax.sql.DataSource;
|
8 |
import javax.sql.DataSource;
|
| 6 |
|
9 |
|
| 7 |
import org.apache.logging.log4j.LogManager;
|
10 |
import org.apache.logging.log4j.LogManager;
|
| Line 17... |
Line 20... |
| 17 |
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
20 |
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
| 18 |
import org.springframework.orm.hibernate5.HibernateTransactionManager;
|
21 |
import org.springframework.orm.hibernate5.HibernateTransactionManager;
|
| 19 |
import org.springframework.orm.hibernate5.LocalSessionFactoryBuilder;
|
22 |
import org.springframework.orm.hibernate5.LocalSessionFactoryBuilder;
|
| 20 |
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
23 |
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
| 21 |
|
24 |
|
| - |
|
25 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| - |
|
26 |
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
| - |
|
27 |
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
| - |
|
28 |
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
| - |
|
29 |
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
| - |
|
30 |
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
| 22 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
31 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 23 |
|
32 |
|
| 24 |
@Configuration
|
33 |
@Configuration
|
| 25 |
@EnableTransactionManagement
|
34 |
@EnableTransactionManagement
|
| 26 |
@ComponentScan("com.spice.profitmandi.*")
|
35 |
@ComponentScan("com.spice.profitmandi.*")
|
| Line 102... |
Line 111... |
| 102 |
dataSource.setUsername(hibernateUserName);
|
111 |
dataSource.setUsername(hibernateUserName);
|
| 103 |
dataSource.setPassword(hibernatePassword);
|
112 |
dataSource.setPassword(hibernatePassword);
|
| 104 |
LOGGER.info("DataSource returned {}", dataSource);
|
113 |
LOGGER.info("DataSource returned {}", dataSource);
|
| 105 |
return dataSource;
|
114 |
return dataSource;
|
| 106 |
}
|
115 |
}
|
| - |
|
116 |
|
| - |
|
117 |
@Bean
|
| - |
|
118 |
public ObjectMapper objectMapper() {
|
| - |
|
119 |
DateTimeFormatter df = new DateTimeFormatterBuilder()
|
| - |
|
120 |
.parseCaseInsensitive()
|
| - |
|
121 |
.append(DateTimeFormatter.ISO_LOCAL_DATE)
|
| - |
|
122 |
.optionalStart()
|
| - |
|
123 |
.appendLiteral('T')
|
| - |
|
124 |
.optionalEnd()
|
| - |
|
125 |
.appendLiteral(' ')
|
| - |
|
126 |
.append(DateTimeFormatter.ISO_LOCAL_TIME)
|
| - |
|
127 |
.toFormatter();
|
| - |
|
128 |
DateTimeFormatter sf = new DateTimeFormatterBuilder()
|
| - |
|
129 |
.parseCaseInsensitive()
|
| - |
|
130 |
.append(DateTimeFormatter.ISO_LOCAL_DATE)
|
| - |
|
131 |
.appendLiteral('T')
|
| - |
|
132 |
.append(DateTimeFormatter.ISO_LOCAL_TIME)
|
| - |
|
133 |
.toFormatter();
|
| - |
|
134 |
LocalDateTimeSerializer serializer = new LocalDateTimeSerializer(sf);
|
| - |
|
135 |
LocalDateTimeDeserializer deserializer = new LocalDateTimeDeserializer(df);
|
| - |
|
136 |
JavaTimeModule jtm = new JavaTimeModule();
|
| - |
|
137 |
jtm.addSerializer(LocalDateTime.class, serializer);
|
| - |
|
138 |
jtm.addDeserializer(LocalDateTime.class, deserializer);
|
| - |
|
139 |
ObjectMapper mapper = new ObjectMapper()
|
| - |
|
140 |
.registerModule(new ParameterNamesModule())
|
| - |
|
141 |
.registerModule(new Jdk8Module())
|
| - |
|
142 |
.registerModule(jtm); // new module, NOT JSR310Module
|
| - |
|
143 |
return mapper;
|
| - |
|
144 |
}
|
| 107 |
|
145 |
|
| 108 |
@Bean
|
146 |
@Bean
|
| 109 |
public Properties getHibernateProperties() {
|
147 |
public Properties getHibernateProperties() {
|
| 110 |
Properties dbProperties = new Properties();
|
148 |
Properties dbProperties = new Properties();
|
| 111 |
dbProperties.put(HIBERNATE_DIALECT, hibernateDialect);
|
149 |
dbProperties.put(HIBERNATE_DIALECT, hibernateDialect);
|