Browse Source

添加日志依赖 和框架版本依赖升级避免已发现的漏洞

andy 1 year ago
parent
commit
09edfa9262

+ 11 - 31
mainFactory/pom.xml

@@ -2,10 +2,12 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
     <parent>
-        <artifactId>dataHandler</artifactId>
-        <groupId>org.bfkj</groupId>
-        <version>1.0-SNAPSHOT</version>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>3.0.6</version>
+        <relativePath/> <!-- lookup parent from repository -->
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>mainFactory</artifactId>
@@ -29,21 +31,6 @@
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
-            <version>2.7.3</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.springframework.boot</groupId>
-                    <artifactId>spring-boot-starter-logging</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>com.vaadin.external.google</groupId>
-                    <artifactId>android-json</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.springframework.security</groupId>
-                    <artifactId>spring-security-core</artifactId>
-                </exclusion>
-            </exclusions>
         </dependency>
 
         <dependency>
@@ -55,13 +42,13 @@
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi</artifactId>
-            <version>4.1.1</version>
+            <version>5.2.2</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi-ooxml</artifactId>
-            <version>4.1.1</version>
+            <version>5.2.2</version>
         </dependency>
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
@@ -93,7 +80,7 @@
         <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
-            <version>8.0.31</version>
+            <version>8.0.33</version>
         </dependency>
 
         <dependency>
@@ -109,14 +96,13 @@
         <dependency>
             <groupId>org.dom4j</groupId>
             <artifactId>dom4j</artifactId>
-            <version>2.0.3</version>
+            <version>2.1.3</version>
         </dependency>
 
         <!--rabbitmq 9-->
         <dependency>
             <groupId>com.rabbitmq</groupId>
             <artifactId>amqp-client</artifactId>
-            <version>5.7.3</version>
         </dependency>
         <dependency>
             <groupId>com.ibm.mq</groupId>
@@ -136,7 +122,7 @@
         <dependency>
             <groupId>org.elasticsearch</groupId>
             <artifactId>elasticsearch</artifactId>
-            <version>7.15.2</version>
+            <version>7.17.9</version>
         </dependency>
 
 
@@ -151,16 +137,10 @@
             <artifactId>nashorn-core</artifactId>
             <version>15.4</version>
         </dependency>
-
-
-        <dependency>
-            <groupId>com.alibaba</groupId>
-            <artifactId>druid</artifactId>
-            <version>1.2.8</version>
-        </dependency>
     </dependencies>
 
     <build>
+
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 20 - 19
mainFactory/src/main/java/org/bfkj/MainFactoryApplication.java

@@ -7,6 +7,8 @@ import org.bfkj.utils.LogUtils;
 import org.bfkj.utils.MapTools;
 import org.bfkj.utils.MyDbHelper;
 import org.bfkj.utils.ScheduleUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.SpringApplication;
@@ -20,7 +22,6 @@ import org.springframework.scheduling.annotation.Scheduled;
 import java.io.File;
 import java.util.*;
 import java.util.logging.Level;
-import java.util.logging.Logger;
 
 /**
  * 初始化
@@ -30,7 +31,7 @@ import java.util.logging.Logger;
 @EnableScheduling
 public class MainFactoryApplication implements InitializingBean {
 
-    private static final Logger logger = Logger.getLogger(MainFactoryApplication.class.getName());
+    private final static Logger logger = LoggerFactory.getLogger(MainFactoryApplication.class);
 
     private static final String INSERT_SQL = "INSERT INTO log_success ( success, location, logContent, createtime, serviceId, workId, event, iNDataContent, outDataContent, calculationLocation, dataObjectId) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
     private static final String ERROR_SQL = "INSERT INTO log_error ( success, location, logContent, createtime, serviceId, workId, event, iNDataContent, outDataContent, calculationLocation, dataObjectId) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
@@ -50,7 +51,7 @@ public class MainFactoryApplication implements InitializingBean {
     public static void main(String[] args) {
         String path = System.getProperty("user.dir"); //获取当前项目的路径
         if (!checkFileDir(path)) {
-            logger.log(Level.SEVERE, "配置文件夹检测失败");
+            logger.error("配置文件夹检测失败");
             return;
         }
         /*获取初始地址*/
@@ -70,18 +71,18 @@ public class MainFactoryApplication implements InitializingBean {
         }
         MyDbHelper myDbHelper = ObjectMap.getordropMyDbHelper(AppConfig.REMOTE_DB_CONNECT);
         if (Objects.nonNull(myDbHelper.getErrorMessage())) {
-            logger.log(Level.SEVERE, "初始化获取MyDbHelper对象异常");
+            logger.error("初始化获取MyDbHelper对象异常");
             return;
         }
         if (!initDB(myDbHelper)) {
-            logger.log(Level.SEVERE, "初始化远程数据库失败");
+            logger.error("初始化远程数据库失败");
             return;
         }
         Runtime.getRuntime().addShutdownHook(new Thread(MainFactoryApplication::currentWorkExit));
         try {
             Map<String, String> hasDeployNodeIDMap = myDbHelper.queryForObject("select Max(deployNodeID) from deploynode where serviceURL = ? ", AppConfig.serviceURL);
             if ("-1".equals(hasDeployNodeIDMap.get("code"))) {
-                logger.log(Level.SEVERE, "初始化获取机器表信息: 执行SQL失败 %s".formatted(hasDeployNodeIDMap.get("message")));
+                logger.error("初始化获取机器表信息: 执行SQL失败 {}",hasDeployNodeIDMap.get("message"));
                 return;
             }
             String workID = hasDeployNodeIDMap.get("returnData");
@@ -90,24 +91,24 @@ public class MainFactoryApplication implements InitializingBean {
             } else {
                 Map<String, String> returnKeyValues = myDbHelper.insertReturnKeyValues("insert into deploynode(serviceURL)  values(?)", AppConfig.serviceURL);
                 if ("-1".equals(returnKeyValues.get("code"))) {
-                    logger.log(Level.SEVERE, "根据serviceURL新增入库失败: " + ("insert into deploynode(serviceURL)  values(?)") + " 参数: " + AppConfig.serviceURL);
+                    logger.error("根据serviceURL新增入库失败: {}{}{}" , "insert into deploynode(serviceURL)  values(?)" , " 参数: " , AppConfig.serviceURL);
                     return;
                 }
                 AppConfig.WORK_ID = returnKeyValues.get("returnData");
                 if (!MapTools.isNumber(AppConfig.WORK_ID)) {
-                    logger.log(Level.SEVERE, "初始化workID异常: " + AppConfig.WORK_ID);
+                    logger.error("初始化workID异常: {}" , AppConfig.WORK_ID);
                     return;
                 }
             }
         } catch (Exception e) {
-            logger.log(Level.SEVERE, "初始化workID异常: " + LogUtils.getException(e));
+            logger.error("初始化workID异常: {}" , LogUtils.getException(e));
             return;
         }
 
         Map<String, Object> serviceListResult = myDbHelper.queryByParamsReturnList("SELECT serviceID,serviceType FROM serviceinfo WHERE workId = ?", AppConfig.WORK_ID);
         List<Map<String, Object>> serviceList = MapTools.getMapList(serviceListResult);
         if (!"0".equals(serviceListResult.get("code")) || null == serviceList) {
-            logger.log(Level.SEVERE, "初始化获取服务异常: " + serviceListResult.get("message"));
+            logger.error("初始化获取服务异常: " + serviceListResult.get("message"));
             return;
         }
         int autoCount = 0;
@@ -121,7 +122,7 @@ public class MainFactoryApplication implements InitializingBean {
                 ServiceInputControl.startOrStop(requestParams, "1");
             }
         }
-        logger.log(Level.INFO, "本机共部署服务个数:" + serviceList.size() + ",启动主动采集个数:" + autoCount);
+        logger.info("本机共部署服务个数:{},启动主动采集个数:{}", serviceList.size(), autoCount);
     }
 
     /**
@@ -146,7 +147,7 @@ public class MainFactoryApplication implements InitializingBean {
         //关闭数据库连接
         ObjectMap.getordropMyDbHelper(AppConfig.REMOTE_DB_CONNECT).close();
         ObjectMap.getordropMyDbHelper(AppConfig.REMOTE_DB_LOG_CONNECT).close();
-        logger.log(Level.INFO, "系统正常退出");
+        logger.info("系统正常退出");
     }
 
     /*创建文件夹*/
@@ -174,7 +175,7 @@ public class MainFactoryApplication implements InitializingBean {
 
         Map<String, String> hasAppMap = myDbHelper.queryForObject("select count(1) hasCount  from t_application where app_id =?", "1");
         if ("-1".equals(hasAppMap.get("code"))) {
-            System.out.println("初始化数据库 查询应用信息,查询失败: " + hasAppMap.get("message"));
+            logger.error("初始化数据库 查询应用信息,查询失败:{} ", hasAppMap.get("message"));
             return false;
         }
         String hasApp = hasAppMap.get("returnData");
@@ -185,7 +186,7 @@ public class MainFactoryApplication implements InitializingBean {
 
         Map<String, String> hasUserApp = myDbHelper.queryForObject("select count(1) hasUser  from t_user where user_id =?", "1");
         if ("-1".equals(hasUserApp.get("code"))) {
-            System.out.println("初始化数据库 查询用户信息信息,查询失败: " + hasAppMap.get("message"));
+            logger.error("初始化数据库 查询用户信息信息,查询失败: {}", hasAppMap.get("message"));
             return false;
         }
         String hasUser = hasUserApp.get("returnData");
@@ -196,7 +197,7 @@ public class MainFactoryApplication implements InitializingBean {
 
         Map<String, String> hasAuthApp = myDbHelper.queryForObject("select count(1) hasAuth  from t_auth");
         if ("-1".equals(hasAuthApp.get("code"))) {
-            System.out.println("初始化数据库 查询权限信息信息,查询失败: " + hasAppMap.get("message"));
+            logger.error("初始化数据库 查询权限信息信息,查询失败: {}", hasAppMap.get("message"));
             return false;
         }
         String hasAuth = hasAuthApp.get("returnData");
@@ -207,7 +208,7 @@ public class MainFactoryApplication implements InitializingBean {
 
         Map<String, String> hasServiceApp = myDbHelper.queryForObject("select count(1) hasService  from serviceinfo");
         if ("-1".equals(hasServiceApp.get("code"))) {
-            System.out.println("初始化数据库 查询用户信息信息,查询失败: " + hasAppMap.get("message"));
+            logger.error("初始化数据库 查询用户信息信息,查询失败: {}", hasAppMap.get("message"));
             return false;
         }
 
@@ -270,7 +271,7 @@ public class MainFactoryApplication implements InitializingBean {
         }
         MyDbHelper logDbHelper = ObjectMap.getordropMyDbHelper(AppConfig.REMOTE_DB_LOG_CONNECT);
         if (Objects.nonNull(logDbHelper.getErrorMessage())) {
-            System.out.println("获取日志数据库失败");
+            logger.error("获取日志数据库失败");
             return;
         }
 
@@ -278,7 +279,7 @@ public class MainFactoryApplication implements InitializingBean {
             logDbHelper.JDBCBatch(INSERT_SQL, logSuccessList, null);
             logDbHelper.JDBCBatch(ERROR_SQL, logErrorList, null);
         } catch (Exception e) {
-            System.out.println("日志记录异常" + LogUtils.getException(e));
+            logger.warn("日志记录异常 {}", LogUtils.getException(e));
         }
     }
 
@@ -297,7 +298,7 @@ public class MainFactoryApplication implements InitializingBean {
             AppConfig.SOURCE_DATA = enableSourceData;
 
         } catch (Exception e) {
-            System.out.println("配置文件中,连接数据库信息错误");
+            logger.error("配置文件中,连接数据库信息错误: {}", e.getMessage());
         }
     }
 }

+ 1 - 1
mainFactory/src/main/java/org/bfkj/protocol/ElasticHandler.java

@@ -16,7 +16,7 @@ import org.elasticsearch.client.RequestOptions;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.client.RestClientBuilder;
 import org.elasticsearch.client.RestHighLevelClient;
-import org.elasticsearch.common.xcontent.XContentType;
+import org.elasticsearch.xcontent.XContentType;
 
 import java.io.IOException;
 import java.util.Arrays;

+ 0 - 8
mainFactory/src/main/java/org/bfkj/utils/DruidParserTools.java

@@ -1,13 +1,5 @@
 package org.bfkj.utils;
 
-import org.dom4j.Attribute;
-import org.dom4j.Element;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 /**
  * 算法工具类
  */

+ 0 - 6
pom.xml

@@ -4,12 +4,6 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
-    <parent>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-starter-parent</artifactId>
-        <version>3.0.4</version>
-        <relativePath/> <!-- lookup parent from repository -->
-    </parent>
 
 
     <groupId>org.bfkj</groupId>