Commit 6fe7031f by QIANGLU

add tomcat module

parent 712be168
......@@ -7,7 +7,7 @@
<groupId>com.matrix</groupId>
<artifactId>spring-boot-agent-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<java.version>1.8</java.version>
......@@ -20,7 +20,7 @@
<dependencies>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>secoo-log-starter</artifactId>
<artifactId>logger-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......@@ -47,6 +47,20 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
</dependencies>
<build>
......
......@@ -3,17 +3,24 @@ package com.matrix.agent.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* @author qianglu
*/
@SpringBootApplication
public class AgentDemoStartup {
public class AgentDemoStartup extends SpringBootServletInitializer {
public static void main(String[] args) {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(AgentDemoStartup.class);
}
public static void main(String[] args) {
//
SpringApplication.run(AgentDemoStartup.class, args);
SpringApplication.run(AgentDemoStartup.class, args);
}
}
}
package com.matrix.agent.demo.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
/**
* 异步线程配置
*
* @author QIANGLU on 2019/9/26
*/
@Configuration
@EnableAsync
@EnableScheduling
public class AsyncConfig {
@Value("${sms.executor.corePoolSize:5}")
private int corePoolSize;
@Value("${sms.executor.maxPoolSize:10}")
private int maxPoolSize;
@Value("${sms.executor.queueCapacity:200}")
private int queueCapacity;
@Bean(name = "mailAsync")
public Executor mailAsync() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(corePoolSize);
executor.setMaxPoolSize(maxPoolSize);
executor.setQueueCapacity(queueCapacity);
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.setThreadNamePrefix("MailExecutor-");
executor.initialize();
return executor;
}
}
\ No newline at end of file
package com.matrix.agent.demo.test;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* @author QIANGLU on 2019-09-02
*/
@Component
public class Test {
@Scheduled(fixedDelay = 1000)
private void fun1() throws Exception {
System.out.println("this is fun 1.");
Thread.sleep(500);
}
private void fun2() throws Exception {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment