XynetServicePayThirdApplication.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package com.xynet.pay;
  2. import org.mybatis.spring.annotation.MapperScan;
  3. import org.springframework.boot.SpringApplication;
  4. import org.springframework.boot.autoconfigure.SpringBootApplication;
  5. import org.springframework.boot.web.servlet.ServletComponentScan;
  6. import org.springframework.cache.annotation.EnableCaching;
  7. import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
  8. import org.springframework.cloud.netflix.feign.EnableFeignClients;
  9. import org.springframework.cloud.netflix.hystrix.EnableHystrix;
  10. import org.springframework.context.annotation.Bean;
  11. import org.springframework.retry.annotation.EnableRetry;
  12. import org.springframework.scheduling.annotation.EnableAsync;
  13. import org.springframework.scheduling.annotation.EnableScheduling;
  14. import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
  15. import org.springframework.transaction.annotation.EnableTransactionManagement;
  16. import java.util.TimeZone;
  17. import java.util.concurrent.Executor;
  18. import java.util.concurrent.ThreadPoolExecutor;
  19. @EnableCaching //开启缓存
  20. @SpringBootApplication
  21. @EnableHystrix
  22. @ServletComponentScan
  23. @EnableTransactionManagement
  24. @EnableDiscoveryClient
  25. @EnableFeignClients
  26. @EnableScheduling
  27. @EnableAsync
  28. @EnableRetry
  29. @MapperScan(basePackages = {"com.xynet.pay.meitu.mapper"})
  30. public class XynetServicePayThirdApplication {
  31. public static void main(String[] args) {
  32. init();
  33. SpringApplication.run(XynetServicePayThirdApplication.class, args);
  34. }
  35. private static void init(){
  36. //设置时区
  37. System.setProperty("user.timezone","Asia/Shanghai");
  38. TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
  39. }
  40. /**
  41. * 公共日志执行线程池配置
  42. *
  43. * @return
  44. */
  45. @Bean(value = "publicLogTaskExecutor")
  46. public Executor publicLogTaskExecutor() {
  47. ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
  48. executor.setThreadNamePrefix("PublicLogTaskExecutor");
  49. executor.setCorePoolSize(10);
  50. executor.setQueueCapacity(200);
  51. executor.setMaxPoolSize(100);
  52. executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy());
  53. executor.initialize();
  54. return executor;
  55. }
  56. }