forked from vmware-tanzu-learning/pal-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPalTrackerApplication.java
More file actions
37 lines (31 loc) · 1.34 KB
/
PalTrackerApplication.java
File metadata and controls
37 lines (31 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package io.pivotal.pal.tracker;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import javax.sql.DataSource;
import java.util.TimeZone;
@SpringBootApplication
public class PalTrackerApplication {
public static void main(String[] args) {
// Make sure the application runs as UTC
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
SpringApplication.run(PalTrackerApplication.class, args);
}
@Bean
TimeEntryRepository timeEntryRepository(DataSource dataSource) {
return new JdbcTimeEntryRepository(dataSource);
}
@Bean
public ObjectMapper jsonObjectMapper() {
return Jackson2ObjectMapperBuilder.json()
.serializationInclusion(JsonInclude.Include.NON_NULL) // Don’t include null values
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) //ISODate
.modules(new JavaTimeModule())
.build();
}
}