Browse Source

采集程序的端口可配置化

chenwen 1 year ago
parent
commit
6bcb27120b

+ 1 - 1
src/main/java/com/hb/proj/gather/scheduler/GatherScheduler.java

@@ -38,7 +38,7 @@ public class GatherScheduler {
 	/**
 	 * 单值1分钟执行一次采集,首次等待1分钟,等待服务启动,设备连接上
 	 */
-	//@Scheduled(fixedRate=60*1000,initialDelay= 60000)  //每分钟执行一次
+	@Scheduled(fixedRate=60*1000,initialDelay= 60000)  //每分钟执行一次
 	public void startGather() {
 		logger.info("定时采集启动...");
 		scheNum+=1;

+ 5 - 1
src/main/java/com/hb/proj/gather/server/NettyGatherRunner.java

@@ -3,6 +3,7 @@ package com.hb.proj.gather.server;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
 import org.springframework.core.annotation.Order;
@@ -16,6 +17,9 @@ public class NettyGatherRunner implements ApplicationRunner {
 
 	private final static Logger logger = LoggerFactory.getLogger(NettyGatherRunner.class);
 	
+	@Value("${gather.port}")
+	private int gatherPort;
+	
 	@Autowired
 	private NettyGatherServer  nettyGatherServer;
 	
@@ -26,7 +30,7 @@ public class NettyGatherRunner implements ApplicationRunner {
 			
 			//(new DataAssembler()).start();
 			DataTransConfig.init();
-			nettyGatherServer.start(9603);
+			nettyGatherServer.start(gatherPort);
 			
 		}).start();
 		

+ 4 - 2
src/main/resources/application-dev.properties

@@ -3,6 +3,8 @@ spring.application.name=智能油田-采集程序
 
 # 应用服务 WEB 访问端口
 server.port=8080
+# 采集程序监听端口
+gather.port=9603
 
 server.servlet.context-path=/zl-opd-gather
 server.tomcat.uri-encoding=UTF-8
@@ -18,9 +20,9 @@ spring.jackson.time-zone=GMT+8
 
 
 #数据库连接池配置
-spring.datasource.url=jdbc:mysql://42.56.120.92:9601/zl_opd?useOldAliasMetadataBehavior=true
+spring.datasource.url=jdbc:mysql://127.0.0.1:3306/zl_opd?useOldAliasMetadataBehavior=true
 spring.datasource.username=root
-spring.datasource.password=zlmysql
+spring.datasource.password=123456
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 spring.datasource.type=com.hb.xframework.dao.util.HikariDataSourceWrap
 spring.datasource.dialect=MySQL

+ 2 - 0
src/main/resources/application-pro.properties

@@ -3,6 +3,8 @@ spring.application.name=智能油田
 
 # 应用服务 WEB 访问端口
 server.port=8080
+# 采集程序监听端口
+gather.port=9603
 
 server.servlet.context-path=/zl
 server.tomcat.uri-encoding=UTF-8