package com.casic.missiles; import com.casic.missiles.socket.BootNettyServer; import com.casic.missiles.socket.service.ISocketService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.PropertySource; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.transaction.annotation.EnableTransactionManagement; import javax.annotation.Resource; /** * SpringBoot方式启动类 * * @author lwh * @Date 2021/06/06 12:06 */ @SpringBootApplication @EnableCaching @EnableTransactionManagement(proxyTargetClass = true) @EnableAsync @Slf4j @PropertySource("classpath:/config/socket.properties") @EnableScheduling public class CasicApplication implements CommandLineRunner { @Value("${socket.port}") private Integer port; @Resource private ISocketService socketService; public static void main(String[] args) { SpringApplication.run(CasicApplication.class, args); log.info("CasicApplication is success!"); } @Async @Override public void run(String... args) { /** * 使用异步注解方式启动netty服务端服务 */ new BootNettyServer(socketService).bind(port); } }