xiao547607 5 年 前
コミット
4098823da7

+ 33 - 0
src/main/java/com/jpsoft/smart/SmartCommunityServerApplication.java

@@ -0,0 +1,33 @@
+package com.jpsoft.smart;
+
+import com.jpsoft.smart.modules.communication.server.TcpServer;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@SpringBootApplication
+@EnableTransactionManagement
+@MapperScan("com.jpsoft.smart.**.dao")
+public class SmartCommunityServerApplication implements CommandLineRunner {
+	@Autowired
+	private TcpServer tcpServer;
+
+	public static void main(String[] args) {
+		SpringApplication.run(SmartCommunityServerApplication.class, args);
+	}
+
+	@Override
+	public void run(String... args) throws Exception {
+		tcpServer.start();
+
+		Runtime.getRuntime().addShutdownHook(new Thread(){
+			@Override
+			public void run() {
+				tcpServer.stop();
+			}
+		});
+	}
+}