66 lines
2.3 KiB
Java
66 lines
2.3 KiB
Java
package com;
|
|
|
|
import com.sv.netty.config.SpringContextHolder;
|
|
import com.sv.netty.netty.BootService;
|
|
import org.mybatis.spring.annotation.MapperScan;
|
|
import org.springframework.boot.SpringApplication;
|
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
import org.springframework.context.ConfigurableApplicationContext;
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
|
/**
|
|
* 项目入口
|
|
*/
|
|
@SpringBootApplication
|
|
@EnableScheduling
|
|
@EnableAsync
|
|
@MapperScan(value = {"com.sv.mapper"})
|
|
public class NettyWeiXinApplication {
|
|
|
|
/**
|
|
* 启动项目
|
|
*
|
|
* @param args 启动参数
|
|
*/
|
|
public static void main(String[] args) {
|
|
// SpringApplication.run(NettyWeiXinApplication.class, args);
|
|
ConfigurableApplicationContext context = SpringApplication.run(NettyWeiXinApplication.class, args);
|
|
SpringContextHolder.setContext(context);
|
|
//启动netty
|
|
BootService bootService = (BootService) context.getBean("bootService");
|
|
bootService.run();
|
|
}
|
|
|
|
|
|
/**
|
|
* 项目可能又使用计划任务的
|
|
*/
|
|
// private int corePoolSize = 5;//线程池维护线程的最少数量
|
|
//
|
|
// private int maxPoolSize = 15;//线程池维护线程的最大数量
|
|
//
|
|
// private int queueCapacity = 5; //缓存队列
|
|
//
|
|
// private int keepAlive = 60;//允许的空闲时间
|
|
// @Bean("scheduledExecutorService")
|
|
// public ScheduledExecutorService initScheduledExecutorService() {
|
|
// ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(400,
|
|
// new BasicThreadFactory.Builder().namingPattern("example-schedule-pool-%d").daemon(true).build());
|
|
// return executorService;
|
|
// }
|
|
// @Bean
|
|
// public Executor executor() {
|
|
// ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
// executor.setCorePoolSize(corePoolSize);
|
|
// executor.setMaxPoolSize(maxPoolSize);
|
|
// executor.setQueueCapacity(queueCapacity);
|
|
// executor.setThreadNamePrefix("mqExecutor-");
|
|
// executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
|
|
// executor.setKeepAliveSeconds(keepAlive);
|
|
// executor.initialize();
|
|
// return executor;
|
|
// }
|
|
}
|