SvrPackAnalyzer.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.yihu.ehr;
  2. import com.yihu.ehr.analyze.config.SchedulerConfig;
  3. import com.yihu.ehr.analyze.service.scheduler.SchedulerService;
  4. import com.yihu.ehr.analyze.service.scheduler.WarningSchedulerService;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.boot.CommandLineRunner;
  7. import org.springframework.boot.SpringApplication;
  8. import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  9. import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
  10. import org.springframework.boot.builder.SpringApplicationBuilder;
  11. import org.springframework.boot.web.support.SpringBootServletInitializer;
  12. import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
  13. import org.springframework.cloud.netflix.feign.EnableFeignClients;
  14. import org.springframework.context.annotation.ComponentScan;
  15. import org.springframework.context.annotation.Configuration;
  16. import org.springframework.data.web.config.EnableSpringDataWebSupport;
  17. import org.springframework.scheduling.annotation.EnableAsync;
  18. import org.springframework.scheduling.annotation.EnableScheduling;
  19. @Configuration
  20. @EnableAutoConfiguration(exclude = {
  21. SecurityAutoConfiguration.class})
  22. @ComponentScan
  23. @EnableDiscoveryClient
  24. @EnableFeignClients
  25. @EnableScheduling
  26. @EnableAsync
  27. @EnableSpringDataWebSupport
  28. public class SvrPackAnalyzer extends SpringBootServletInitializer implements CommandLineRunner {
  29. @Autowired
  30. private SchedulerService schedulerService;
  31. @Autowired
  32. private SchedulerConfig schedulerConfig;
  33. @Autowired
  34. private WarningSchedulerService warningSchedulerService;
  35. public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
  36. SpringApplication.run(SvrPackAnalyzer.class, args);
  37. }
  38. @Override
  39. public void run(String... strings) throws Exception {
  40. schedulerService.addJob(schedulerConfig.getJobMinSize(), schedulerConfig.getCronExp());
  41. warningSchedulerService.init();
  42. }
  43. @Override
  44. protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
  45. return application.sources(SvrPackAnalyzer.class);
  46. }
  47. }