diff --git a/dsBase/Dockerfile b/dsBase/Dockerfile index 5f1951fe..7426bead 100644 --- a/dsBase/Dockerfile +++ b/dsBase/Dockerfile @@ -6,17 +6,19 @@ WORKDIR /root # ENV TZ这样的用法通常是用来设置时区环境变量,TZ代表Time Zone ENV TZ=Asia/Shanghai +# 声明变量 +ENV file_name="dsBase-jar-with-dependencies.jar" + # 让容器内部正常显示中文 -ENV LANG C.UTF-8 +ENV LANG=C.UTF-8 -# 将target文件夹下的jar包gw-charge.jar复制到容器的/root目录下 -COPY ./lib /root/lib -COPY ./target /root/target +# 将jar包复制到容器的/root目录下 +COPY $file_name /root/$file_name #设置这个环境变量后,您可以在Docker容器中启动Java应用程序时使用这些参数。 ENV JAVA_OPTS="-Xms1024m -Xmx2048m" # 标识为生产环境 -ENV WORKING_ENV="pro" +ENV WORKING_ENV="dev" -ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -cp /root/target/classes:/root/lib/* com.dsideal.base.BaseApplication" ] +ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar $file_name" ] diff --git a/dsBase/pom.xml b/dsBase/pom.xml index fbe2d67b..b9a9dc9d 100644 --- a/dsBase/pom.xml +++ b/dsBase/pom.xml @@ -55,12 +55,6 @@ minio ${minio.version} - - - javax.xml.bind - jaxb-api - 2.3.1 - net.sf.json-lib @@ -249,7 +243,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.6.1 + ${maven-compiler-plugin.version} 21 21 @@ -262,11 +256,11 @@ org.apache.maven.plugins maven-assembly-plugin - 3.3.0 + ${maven-assembly-plugin.version} - - src/main/resources/package.xml - + + jar-with-dependencies + com.dsideal.base.BaseApplication @@ -283,6 +277,18 @@ + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + default-jar + none + + + \ No newline at end of file diff --git a/dsBase/src/main/java/com/dsideal/base/Teacher/Model/TeacherModel.java b/dsBase/src/main/java/com/dsideal/base/Teacher/Model/TeacherModel.java index f5dff8be..4420c526 100644 --- a/dsBase/src/main/java/com/dsideal/base/Teacher/Model/TeacherModel.java +++ b/dsBase/src/main/java/com/dsideal/base/Teacher/Model/TeacherModel.java @@ -153,7 +153,7 @@ public class TeacherModel { //继续保存人员职务与分管工作 //1、清除此人的职务与分管工作 sql = Db.getSql("teacher.deleteDutuesAndChargeByPersonId"); - Db.update(sql, operator, IpUtil.ipToLong(ip_address), person_id); + Db.update(sql, person_id); String nowDutiesStr = ""; diff --git a/dsBase/src/main/java/com/dsideal/base/Util/CommonUtil.java b/dsBase/src/main/java/com/dsideal/base/Util/CommonUtil.java index f7195ab0..1145b67d 100644 --- a/dsBase/src/main/java/com/dsideal/base/Util/CommonUtil.java +++ b/dsBase/src/main/java/com/dsideal/base/Util/CommonUtil.java @@ -1,5 +1,6 @@ package com.dsideal.base.Util; +import cn.hutool.core.io.IoUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.dsideal.base.BaseApplication; @@ -51,26 +52,9 @@ public class CommonUtil { * @return 文件内容 * @throws IOException */ - public static String txt2String(String path) throws IOException { + public static String txt2String(String path) { InputStream is = CommonUtil.class.getClassLoader().getResourceAsStream(path); - BufferedInputStream bis = null; - StringBuilder sb = new StringBuilder(); - try { - bis = new BufferedInputStream(is); - byte[] temp = new byte[1024]; - int len; - while ((len = bis.read(temp)) != -1) { - sb.append(new String(temp, 0, len, StandardCharsets.UTF_8)); - } - } finally { - if (bis != null) { - bis.close(); - } - if (is != null) { - is.close(); - } - } - return sb.toString(); + return IoUtil.read(is, "UTF-8"); } /** diff --git a/dsBase/src/main/resources/Sql/teacher.sql b/dsBase/src/main/resources/Sql/teacher.sql index 5b33494c..2fd7e239 100644 --- a/dsBase/src/main/resources/Sql/teacher.sql +++ b/dsBase/src/main/resources/Sql/teacher.sql @@ -85,6 +85,6 @@ --删除指定人员的职务与分管工作 #sql("deleteDutuesAndChargeByPersonId") - update t_person_duty_charge set b_use=0,operator=?,ip_address=? where person_id=? + delete from t_person_duty_charge where person_id=? #end #end \ No newline at end of file diff --git a/dsBase/src/main/resources/package.xml b/dsBase/src/main/resources/package.xml deleted file mode 100644 index b759bd85..00000000 --- a/dsBase/src/main/resources/package.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - bin - - - zip - - - - - - - false - - lib - - false - - - - - - - - - ${project.basedir}/src/main/resources/${env} - /config - - - - - *.* - - - - - - ${project.basedir}/src/main/resources/${env} - - - scf*.xml - - - - - - ${project.build.directory} - - - *.jar - - - - - - ${project.build.directory}/jar - - - lib/*.jar - - - *.jar - - - - \ No newline at end of file diff --git a/dsBase/生成依赖jar.bat b/dsBase/生成依赖jar.bat deleted file mode 100644 index 4ecb7b0d..00000000 --- a/dsBase/生成依赖jar.bat +++ /dev/null @@ -1,8 +0,0 @@ -mkdir lib -cd lib -del *.jar /q -cd .. -mvn -f pom.xml dependency:copy-dependencies -DoutputDirectory=lib - -@echo 黄海完成了! -pause diff --git a/dsGw/Dockerfile b/dsGw/Dockerfile index bf25b67b..bbf30a65 100644 --- a/dsGw/Dockerfile +++ b/dsGw/Dockerfile @@ -6,18 +6,19 @@ WORKDIR /root # ENV TZ这样的用法通常是用来设置时区环境变量,TZ代表Time Zone ENV TZ=Asia/Shanghai -# 让容器内部正常显示中文 -ENV LANG C.UTF-8 +# 声明变量 +ENV file_name="dsGw-jar-with-dependencies.jar" +# 让容器内部正常显示中文 +ENV LANG=C.UTF-8 -# 将target文件夹下的jar包gw-charge.jar复制到容器的/root目录下 -COPY ./lib /root/lib -COPY ./target /root/target +# 将jar包复制到容器的/root目录下 +COPY $file_name /root/$file_name #设置这个环境变量后,您可以在Docker容器中启动Java应用程序时使用这些参数。 ENV JAVA_OPTS="-Xms1024m -Xmx2048m" # 标识为生产环境 -ENV WORKING_ENV="pro" +ENV WORKING_ENV="dev" -ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -cp /root/target/classes:/root/lib/* com.dsideal.gw.GwApplication" ] +ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar $file_name" ] diff --git a/dsGw/pom.xml b/dsGw/pom.xml index 2733f4e0..cce70816 100644 --- a/dsGw/pom.xml +++ b/dsGw/pom.xml @@ -132,7 +132,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.6.1 + ${maven-compiler-plugin.version} 21 21 @@ -145,14 +145,14 @@ org.apache.maven.plugins maven-assembly-plugin - 3.3.0 + ${maven-assembly-plugin.version} - - src/main/resources/package.xml - + + jar-with-dependencies + - com.dsideal.base.BaseApplication + com.dsideal.gw.GwApplication @@ -166,6 +166,18 @@ + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + default-jar + none + + + diff --git a/dsGw/src/main/java/com/dsideal/gw/Util/CommonUtil.java b/dsGw/src/main/java/com/dsideal/gw/Util/CommonUtil.java index 54434039..4c90fe83 100644 --- a/dsGw/src/main/java/com/dsideal/gw/Util/CommonUtil.java +++ b/dsGw/src/main/java/com/dsideal/gw/Util/CommonUtil.java @@ -1,5 +1,6 @@ package com.dsideal.gw.Util; +import cn.hutool.core.io.IoUtil; import com.jfinal.kit.PathKit; import org.apache.commons.codec.digest.DigestUtils; import org.slf4j.Logger; @@ -41,26 +42,9 @@ public class CommonUtil { * @return 文件内容 * @throws IOException */ - public static String txt2String(String path) throws IOException { + public static String txt2String(String path) { InputStream is = CommonUtil.class.getClassLoader().getResourceAsStream(path); - BufferedInputStream bis = null; - StringBuilder sb = new StringBuilder(); - try { - bis = new BufferedInputStream(is); - byte[] temp = new byte[1024]; - int len; - while ((len = bis.read(temp)) != -1) { - sb.append(new String(temp, 0, len, StandardCharsets.UTF_8)); - } - } finally { - if (bis != null) { - bis.close(); - } - if (is != null) { - is.close(); - } - } - return sb.toString(); + return IoUtil.read(is, "UTF-8"); } /** diff --git a/dsGw/生成依赖jar.bat b/dsGw/生成依赖jar.bat deleted file mode 100644 index 4ecb7b0d..00000000 --- a/dsGw/生成依赖jar.bat +++ /dev/null @@ -1,8 +0,0 @@ -mkdir lib -cd lib -del *.jar /q -cd .. -mvn -f pom.xml dependency:copy-dependencies -DoutputDirectory=lib - -@echo 黄海完成了! -pause diff --git a/dsRes/Dockerfile b/dsRes/Dockerfile index 752b201e..9d50a491 100644 --- a/dsRes/Dockerfile +++ b/dsRes/Dockerfile @@ -6,18 +6,19 @@ WORKDIR /root # ENV TZ这样的用法通常是用来设置时区环境变量,TZ代表Time Zone ENV TZ=Asia/Shanghai -# 让容器内部正常显示中文 -ENV LANG C.UTF-8 +# 声明变量 +ENV file_name="dsRes-jar-with-dependencies.jar" +# 让容器内部正常显示中文 +ENV LANG=C.UTF-8 -# 将target文件夹下的jar包gw-charge.jar复制到容器的/root目录下 -COPY ./lib /root/lib -COPY ./target /root/target +# 将jar包复制到容器的/root目录下 +COPY $file_name /root/$file_name #设置这个环境变量后,您可以在Docker容器中启动Java应用程序时使用这些参数。 ENV JAVA_OPTS="-Xms1024m -Xmx2048m" # 标识为生产环境 -ENV WORKING_ENV="pro" +ENV WORKING_ENV="dev" -ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -cp /root/target/classes:/root/lib/* com.dsideal.resource.ResApplication" ] +ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar $file_name" ] diff --git a/dsRes/pom.xml b/dsRes/pom.xml index 5472a8e9..9bb06225 100644 --- a/dsRes/pom.xml +++ b/dsRes/pom.xml @@ -59,12 +59,6 @@ japidocs 1.4.4 - - - com.google.code.gson - gson - 2.11.0 - javax.xml.bind jaxb-api @@ -92,11 +86,6 @@ jackson-core 2.17.2 - - com.fasterxml.jackson.core - jackson-databind - 2.17.2 - net.sf.json-lib @@ -191,13 +180,6 @@ 2.20.0 - - - org.slf4j - slf4j-simple - 1.7.36 - - com.fasterxml.jackson.core jackson-databind @@ -244,11 +226,7 @@ jjwt 0.7.0 - - javax.xml.bind - jaxb-api - 2.3.0 - + com.sun.xml.bind jaxb-impl @@ -259,11 +237,6 @@ jaxb-core 2.3.0 - - javax.activation - activation - 1.1.1 - @@ -279,7 +252,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.6.1 + ${maven-compiler-plugin.version} 21 21 @@ -292,11 +265,11 @@ org.apache.maven.plugins maven-assembly-plugin - 3.3.0 + ${maven-assembly-plugin.version} - - src/main/resources/package.xml - + + jar-with-dependencies + com.dsideal.base.BaseApplication @@ -313,6 +286,18 @@ + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + default-jar + none + + + \ No newline at end of file diff --git a/dsRes/src/main/java/com/dsideal/resource/Util/CommonUtil.java b/dsRes/src/main/java/com/dsideal/resource/Util/CommonUtil.java index fc84e1c5..efab7156 100644 --- a/dsRes/src/main/java/com/dsideal/resource/Util/CommonUtil.java +++ b/dsRes/src/main/java/com/dsideal/resource/Util/CommonUtil.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.jfinal.kit.PathKit; import com.jfinal.kit.StrKit; +import cn.hutool.core.io.IoUtil; import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Record; import org.apache.commons.codec.binary.Base64; @@ -48,26 +49,9 @@ public class CommonUtil { * @return 文件内容 * @throws IOException */ - public static String txt2String(String path) throws IOException { + public static String txt2String(String path) { InputStream is = CommonUtil.class.getClassLoader().getResourceAsStream(path); - BufferedInputStream bis = null; - StringBuilder sb = new StringBuilder(); - try { - bis = new BufferedInputStream(is); - byte[] temp = new byte[1024]; - int len; - while ((len = bis.read(temp)) != -1) { - sb.append(new String(temp, 0, len, StandardCharsets.UTF_8)); - } - } finally { - if (bis != null) { - bis.close(); - } - if (is != null) { - is.close(); - } - } - return sb.toString(); + return IoUtil.read(is, "UTF-8"); } /** diff --git a/dsRes/生成依赖jar.bat b/dsRes/生成依赖jar.bat deleted file mode 100644 index 4ecb7b0d..00000000 --- a/dsRes/生成依赖jar.bat +++ /dev/null @@ -1,8 +0,0 @@ -mkdir lib -cd lib -del *.jar /q -cd .. -mvn -f pom.xml dependency:copy-dependencies -DoutputDirectory=lib - -@echo 黄海完成了! -pause diff --git a/dsUtils/src/main/java/com/dsideal/Publish.java b/dsUtils/src/main/java/com/dsideal/Publish.java index d09d28af..1d102d55 100644 --- a/dsUtils/src/main/java/com/dsideal/Publish.java +++ b/dsUtils/src/main/java/com/dsideal/Publish.java @@ -43,13 +43,14 @@ public class Publish { //这个项目是什么类型? String projectAttribute = PublishUtil.getProjectAttribute(choiceProject, listProject); - String workingPath = null, projectName = null, localLibPath = null; + String workingPath = null, projectName = null, localLibPath = null,devProjectName = null; boolean isStatic = false; for (ProjectBean projectBean : listProject) { if (projectBean.getId() == choiceProject) { String basedir = new File(System.getProperty("user.dir")).getCanonicalPath(); workingPath = basedir + "\\" + projectBean.getDevProjectName() + "\\"; projectName = projectBean.getPublishProjectName(); + devProjectName= projectBean.getDevProjectName(); if (FileUtil.exist(workingPath + "lib")) { localLibPath = workingPath + "lib\\"; } @@ -60,7 +61,7 @@ public class Publish { isStatic = true; } //开始打包 - Kv ret = PublishUtil.publish(projectName, isStatic, workingPath, localLibPath, choiceWarehouse, choiceConfig); + Kv ret = PublishUtil.publish(projectName,devProjectName, isStatic, workingPath, localLibPath, choiceWarehouse, choiceConfig); System.out.println("测试运行一下容器吧"); if (ret.getStr("project_port") != null) { diff --git a/dsUtils/src/main/java/com/dsideal/Utils/PublishUtil.java b/dsUtils/src/main/java/com/dsideal/Utils/PublishUtil.java index 8f91a9ff..2b14ea99 100644 --- a/dsUtils/src/main/java/com/dsideal/Utils/PublishUtil.java +++ b/dsUtils/src/main/java/com/dsideal/Utils/PublishUtil.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.ZipUtil; import com.alibaba.fastjson2.JSONObject; import com.jfinal.kit.Kv; import com.jfinal.kit.PathKit; +import com.jfinal.kit.PropKit; import com.jfinal.kit.StrKit; import java.io.*; @@ -63,12 +64,8 @@ public class PublishUtil { * docker tag 19a54d2204aa registry.cn-hangzhou.aliyuncs.com/yltcharge/jdk:21 * docker push registry.cn-hangzhou.aliyuncs.com/yltcharge/jdk:21 */ - public static Kv publish(String projectName, boolean isStatic, String workingPath, String localLibPath, Kv choiceWarehouse, String choiceConfig) throws Exception { - //判断是不是有需要批处理的生成JAR的过程 - String cmdPath = workingPath + "生成依赖jar.bat"; - if (FileUtil.exist(cmdPath)) { - ExecBatchCmd(cmdPath); - } + public static Kv publish(String projectName, String devProjectName, boolean isStatic, String workingPath, String localLibPath, Kv choiceWarehouse, String choiceConfig) throws Exception { + System.out.println("正在生成" + projectName + "的镜像..."); //配置文件 String path = PathKit.getRootClassPath() + "\\publishImage.json"; @@ -104,38 +101,24 @@ public class PublishUtil { ssh.upload(workingPath + "Dockerfile", remotePath + "Dockerfile"); } - if (!StrKit.isBlank(localLibPath)) { - System.out.println("正在创建lib目录..."); - ssh.mkdir(remotePath + "lib"); - //遍历lib目录下的文件 - for (File file : FileUtil.loopFiles(localLibPath)) { - System.out.println("正在上传jar包:" + file.getName()); - ssh.upload(file.getAbsolutePath(), remotePath + "lib/" + file.getName()); + System.out.println("正在上传" + projectName + "的jar包..."); + //上传jar包 + String fatjarName = devProjectName + "-jar-with-dependencies.jar"; + String localFile = workingPath + "target/" + fatjarName; + //获取项目端口 + String undertow_dev = workingPath.replace("\\","/") + "target/classes/undertow_dev.properties"; + List list=FileUtil.readLines(undertow_dev, "UTF-8"); + for (String line : list) { + if (line.contains("undertow.port")) { + String[] split = line.split("="); + project_port = split[1]; + break; } } - - //打包target为zip - if (FileUtil.isDirectory(workingPath + "target")) { - String localFile = workingPath + "target.zip"; - if (FileUtil.exist(localFile)) { - FileUtil.del(localFile); - } - System.out.println("正在上传target.zip..."); - // 将目录打包成ZIP文件,不包含目录本身,只包含目录下的文件和子目录 - ZipUtil.zip(workingPath + "target", localFile, true); + if (FileUtil.exist(localFile)) { + System.out.println("正在上传" + fatjarName + "..."); //上传 - ssh.upload(localFile, remotePath + "target.zip"); - //删除target.zip - FileUtil.del(localFile); - //解压缩 - System.out.println("正在解压缩target.zip..."); - ssh.exec("cd " + remotePath + " && unzip target.zip"); - ssh.exec("cd " + remotePath + " && rm -rf target.zip"); - - //获取项目端口 - String undertow_dev = remotePath + "target/classes/undertow_dev.properties"; - String cmd = "grep '^undertow\\.port=' " + undertow_dev + " | awk -F'=' '{print $2}'"; - project_port = ssh.exec(cmd).getStr("message").replace("[", "").replace("]", ""); + ssh.upload(localFile, remotePath + fatjarName); } //处理静态文件 @@ -150,7 +133,7 @@ public class PublishUtil { break; } } - String localFile = workingPath.substring(0, pos) + "\\static.zip"; + localFile = workingPath.substring(0, pos) + "\\static.zip"; if (FileUtil.exist(localFile)) { FileUtil.del(localFile); } diff --git a/pom.xml b/pom.xml index 1140014c..5dde7787 100644 --- a/pom.xml +++ b/pom.xml @@ -62,5 +62,9 @@ 5.2.5 2.3 + + 3.10.1 + 3.7.1 + 3.2.2 \ No newline at end of file diff --git a/操作文档/7、DataEase.md b/操作文档/7、DataEase.md index 470fed6f..1a2f05ac 100644 --- a/操作文档/7、DataEase.md +++ b/操作文档/7、DataEase.md @@ -145,3 +145,12 @@ remote_port=27081 ![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202409131316541.png) ![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202409131323392.png) + + + +在华为云上部署的DataEaseV2 + +117.78.60.214 52025 +DsIdeal@123 + +![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202410171024499.png)