FcbProjectManagerApplication.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package fcb.project.manager;
  2. import com.fasterxml.jackson.databind.ObjectMapper;
  3. import com.fasterxml.jackson.databind.SerializationFeature;
  4. import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
  5. import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
  6. import org.mybatis.spring.annotation.MapperScan;
  7. import org.springframework.boot.SpringApplication;
  8. import org.springframework.boot.autoconfigure.SpringBootApplication;
  9. import org.springframework.boot.builder.SpringApplicationBuilder;
  10. import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
  11. import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
  12. import org.springframework.cloud.openfeign.EnableFeignClients;
  13. import org.springframework.context.annotation.Bean;
  14. import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
  15. import java.time.LocalDateTime;
  16. import java.time.format.DateTimeFormatter;
  17. /**
  18. * @author abnerhou
  19. * @date 2021/1/5 12:25
  20. * @desciption
  21. */
  22. @EnableFeignClients
  23. //@NacosPropertySource(dataId = "abner-test", autoRefreshed = true)
  24. @EnableDiscoveryClient
  25. @SpringBootApplication(scanBasePackages = {"fdage.back.sdk.core" , "fcb.project.manager" , "fdage.back.sdk.base.swagger"})
  26. @MapperScan(basePackages = {"fcb.project.manager.base.dao"})
  27. public class FcbProjectManagerApplication extends SpringBootServletInitializer {
  28. @Bean
  29. public ObjectMapper serializingObjectMapper() {
  30. JavaTimeModule module = new JavaTimeModule();
  31. LocalDateTimeDeserializer localDateTimeDeserializer =
  32. new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
  33. module.addDeserializer(LocalDateTime.class, localDateTimeDeserializer);
  34. ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
  35. .modules(module)
  36. .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
  37. .build();
  38. return objectMapper;
  39. }
  40. @Override
  41. protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
  42. return application.sources(FcbProjectManagerApplication.class);
  43. }
  44. public static void main(String[] args) {
  45. SpringApplication springApplication = new SpringApplication(FcbProjectManagerApplication.class);
  46. springApplication.run(args);
  47. }
  48. }