HuangHai 9 months ago
commit 20386bfcb1

@ -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" ]

@ -55,12 +55,6 @@
<artifactId>minio</artifactId>
<version>${minio.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!--引用json库-->
<dependency>
<groupId>net.sf.json-lib</groupId>
@ -249,7 +243,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>21</source>
<target>21</target>
@ -262,11 +256,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<descriptors>
<descriptor>src/main/resources/package.xml</descriptor> <!-- 配置文件路径 -->
</descriptors>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.dsideal.base.BaseApplication</mainClass>
@ -283,6 +277,18 @@
</execution>
</executions>
</plugin>
<!-- 禁用默认的 jar 打包插件,防止生成额外的 jar 文件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -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 = "";

@ -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");
}
/**

@ -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

@ -1,67 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<!-- 最终打包文件的后缀,格式为 ${fileName}-bin -->
<id>bin</id>
<!-- 最终打包成一个用于发布的zip文件 -->
<formats>
<format>zip</format>
</formats>
<!-- 把依赖的jar包打包进zip的lib目录下-->
<dependencySets>
<dependencySet>
<!-- 不使用项目的artifact -->
<useProjectArtifact>false</useProjectArtifact>
<!-- 打包进zip文件下的lib目录中 -->
<outputDirectory>lib</outputDirectory>
<!-- 第三方jar不要解压 -->
<unpack>false</unpack>
</dependencySet>
</dependencySets>
<!-- 文件配置 -->
<fileSets>
<!-- 把项目的配置文件打包进zip包的config目录下 -->
<fileSet>
<!-- 配置项目中需要被打包的文件的存储路径 -->
<directory>${project.basedir}/src/main/resources/${env}</directory>
<outputDirectory>/config</outputDirectory>
<includes>
<!-- 可以指定单个文件 -->
<!--<include>project.config</include>-->
<!-- 可以直接指定所有文件 -->
<include>*.*</include>
</includes>
</fileSet>
<!-- 把项目的配置文件打包进zip包的根目录下 -->
<fileSet>
<directory>${project.basedir}/src/main/resources/${env}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>scf*.xml</include>
</includes>
</fileSet>
<!-- 把项目自己编译出来根目录下的jar文件打包进zip文件的根目录 -->
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<!-- 把项目自己编译出来的jar文件夹下的jar文件去除第三方jar打包进zip文件的根目录 -->
<fileSet>
<directory>${project.build.directory}/jar</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>lib/*.jar</exclude>
</excludes>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>

@ -1,8 +0,0 @@
mkdir lib
cd lib
del *.jar /q
cd ..
mvn -f pom.xml dependency:copy-dependencies -DoutputDirectory=lib
@echo 黄海完成了!
pause

@ -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" ]

@ -132,7 +132,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>21</source>
<target>21</target>
@ -145,14 +145,14 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<descriptors>
<descriptor>src/main/resources/package.xml</descriptor> <!-- 配置文件路径 -->
</descriptors>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.dsideal.base.BaseApplication</mainClass>
<mainClass>com.dsideal.gw.GwApplication</mainClass>
</manifest>
</archive>
</configuration>
@ -166,6 +166,18 @@
</execution>
</executions>
</plugin>
<!-- 禁用默认的 jar 打包插件,防止生成额外的 jar 文件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -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");
}
/**

@ -1,8 +0,0 @@
mkdir lib
cd lib
del *.jar /q
cd ..
mvn -f pom.xml dependency:copy-dependencies -DoutputDirectory=lib
@echo 黄海完成了!
pause

@ -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" ]

@ -59,12 +59,6 @@
<artifactId>japidocs</artifactId>
<version>1.4.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
@ -92,11 +86,6 @@
<artifactId>jackson-core</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.2</version>
</dependency>
<!--引用json库-->
<dependency>
<groupId>net.sf.json-lib</groupId>
@ -191,13 +180,6 @@
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
@ -244,11 +226,7 @@
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
@ -259,11 +237,6 @@
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<build>
<!--不加此项,文件名中就会多出一个版本号-->
@ -279,7 +252,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>21</source>
<target>21</target>
@ -292,11 +265,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<descriptors>
<descriptor>src/main/resources/package.xml</descriptor> <!-- 配置文件路径 -->
</descriptors>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.dsideal.base.BaseApplication</mainClass>
@ -313,6 +286,18 @@
</execution>
</executions>
</plugin>
<!-- 禁用默认的 jar 打包插件,防止生成额外的 jar 文件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -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");
}
/**

@ -1,8 +0,0 @@
mkdir lib
cd lib
del *.jar /q
cd ..
mvn -f pom.xml dependency:copy-dependencies -DoutputDirectory=lib
@echo 黄海完成了!
pause

@ -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) {

@ -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<String> 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);
}

@ -62,5 +62,9 @@
<poi.version>5.2.5</poi.version>
<!--yaml文件读取-->
<snakeyaml.version>2.3</snakeyaml.version>
<!--maven插件版本号-->
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
</properties>
</project>

@ -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)

Loading…
Cancel
Save