Blame view

src/main/java/com/objecteye/VehicleApplication.java 1.52 KB
c83b5b39   Liu Haoyu   项目创建, 集成spring-se...
1
2
  package com.objecteye;
  
c83b5b39   Liu Haoyu   项目创建, 集成spring-se...
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
  import com.objecteye.websocket.SelectMongoData;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.context.ConfigurableApplicationContext;
  import org.springframework.context.annotation.Bean;
  import org.springframework.scheduling.TaskScheduler;
  import org.springframework.scheduling.annotation.EnableScheduling;
  import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
  import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
  import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  import org.springframework.transaction.annotation.EnableTransactionManagement;
  
  @SpringBootApplication
  @EnableTransactionManagement
  @EnableScheduling
  @EnableWebSecurity
  @EnableGlobalMethodSecurity(prePostEnabled = true)
  public class VehicleApplication {
  
      public static void main(String[] args) {
          ConfigurableApplicationContext run = SpringApplication.run(VehicleApplication.class, args);
  
          //存储系统开始运行时间
          SelectMongoData selectMongoData = run.getBean(SelectMongoData.class);
          selectMongoData.setSystemStartTime();
c83b5b39   Liu Haoyu   项目创建, 集成spring-se...
28
29
30
31
32
33
34
35
36
37
38
      }
  
      @Bean
      public TaskScheduler taskScheduler() {
  
          ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
          threadPoolTaskScheduler.setPoolSize(3);
          threadPoolTaskScheduler.initialize();
          return threadPoolTaskScheduler;
      }
  }