tsurumure 10 сар өмнө
parent
commit
6d0927eed1

+ 1 - 1
.gitignore

@@ -37,7 +37,7 @@ build/
 
 ### Maven ###
 target/
-libs/
+__libs/
 pom.xml.tag
 pom.xml.releaseBackup
 pom.xml.versionsBackup

+ 38 - 44
README.md

@@ -1,77 +1,71 @@
 
-#### 架构
+### 架构
 * Ubuntu 22.04 + JDK 19.0.2 + Maven 3.8.1
 * Docker 25.0.4 + Docker-Compose 2.6.1 + Gogs + Drone
 * MySQL 8.0.31 + Redis 5.0.14.1
-* Springboot 3.1.1
+* Springboot 3.1.1 + Mybatis-plus 3.5.3.2
 
-#### 配置
-Maven settings 用户配置
+### 配置
+Maven 配置 (用户配置)
+
+(阿里源通用配置,无私库,无第三方库,)
 ```
 ./configuration/.m2/settings.xml
 ```
 
-
-## 打包
-使用 maven 打包应用程序 .jar
-```bash
-# 默认 application-local.yml
-mvn clean package
-# 使用 application-dev.yml
-mvn clean package -P dev
+### 手动部署
+第三方JAR包在 `./configuration/.m2/repository` 目录,命令添加到本地 Maven 仓库
+```java
+mvn install:install-file -Dfile=configuration/.m2/repository/ziniao-sdk-java-5.1.0.jar -DgroupId=com.ziniao -DartifactId=ziniao-sdk-java -Dversion=5.1.0 -Dpackaging=jar
+// 如果出现拒绝访问,则需要使用管理员权限执行命令
 ```
-注意:外部JAR包目录在 `./configuration/.m2/repository`,本地构建需要按照路径拷贝
 
-## Debug
-Window 启动 (后台启动)
+
+首次部署需在 pom.xml 中去除 `copy-dependencies` 注释,启用分包功能 (将包分离到 `libs` 文件夹中),像这样:
 ```
-# 使用 PowerShell 终端执行以下命令
-$ cd D:\CodeJava\QuickLaunchSpring\BackendSys
-# 启动
-$ Start-Process javaw -ArgumentList "-Dloader.path=./libs -jar ./target/backendsys-1.0.0.jar" -RedirectStandardOutput "./target/backendsys-1.0.0.log" -RedirectStandardError "./target/backendsys-1.0.0.err.log" -NoNewWindow -Wait
-# 查看控制台
-$ Get-Content -Path "./target/backendsys-1.0.0.log" -Wait
-# 关闭
-$ netstat -ano | findstr 48080
-// TCP    0.0.0.0:48080     0.0.0.0:0     LISTENING      4812
-# 杀掉进程
-$ taskkill /f /pid 25068
+/home/www/project/BackendSys/libs
 ```
+将分离出来的文件,上传到远程服务器目录
 
-Ubuntu 启动
+执行打包命令:
+```
+mvn clean package
+mvn clean package -P dev
 ```
-# 安装 nodup (Ubuntu-22.04 虚拟机可能需要安装)
+
+#### Ubuntu 部署
+```java
+// 安装 nodup (Ubuntu-22.04 虚拟机可能需要安装)
 sudo apt install perforate -y
-# 后台执行 (手动上传 libs 依赖包)
-nohup java -Dloader.path=/home/www/project/BackendSys/libs -jar /home/www/project/BackendSys/target/backendsys-1.0.0.jar > backendsys.log&
-# 监视日志
-tail -f nohup.out
-# 查看已执行的
-ps aux | grep java
-# 关闭进程
-kill 158644
+
+// 启动 (libs文件夹与.jar包同级)
+// sh backendsys.sh restart
+sh backendsys.sh start
+
+// 监视日志
+tail -f backendsys.log
 ```
-注意:第一次部署 **需要手动上传 libs** /home/www/project/BackendSys/libs
 
-要在本地构建分包 (Pom -> copy-dependencies):$ mvn clean package
 
-需要设置权限,否则无法上传:$ chown ubuntu:ubuntu /home/www/project/BackendSys/libs
 
 
-## 项目开发指南
-### 主要目录说明
+
+
+
+### 项目开发指南
+#### 主要目录说明
 * (database/) 存放数据库.sql文件的目录
 * (config/Security/SecurityConfig/) Security放行白名单/跨域资源配置
 * (config/SwaggerConfig/) Swagger文档配置
 * (filter/JwtAuthenticationFilter/) JWT放行白名单配置
 * (exception/GlobalExceptionHandler/) 全局异常处理类
 
-### 更改项目名称
+#### 更改项目名称
 - cmd + Shift + F 将 com.xxx 名称进行全局替换;
 - 将 src/main/java/com/xxx 名称进行修改
 
-## 约束与规范
-### 1.变量
+### 约束与规范
+#### 1.变量
 1) 所有返回值的输出字段,使用 `蛇形命名法` (单词之间使用下划线 _ 分隔,所有字母一般都小写)
 2表字段的初始值及赋值,尽量不为 0,以及不从 0 开始
 

+ 0 - 4
configuration/.m2/repository/com/ziniao/ziniao-sdk-java/5.1.0/_remote.repositories

@@ -1,4 +0,0 @@
-#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
-#Mon Apr 22 13:44:03 CST 2024
-ziniao-sdk-java-5.1.0.jar>rdc-releases=
-ziniao-sdk-java-5.1.0.pom>rdc-releases=

+ 0 - 9
configuration/.m2/repository/com/ziniao/ziniao-sdk-java/5.1.0/ziniao-sdk-java-5.1.0.jar.lastUpdated

@@ -1,9 +0,0 @@
-#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
-#Sun Apr 28 13:15:15 CST 2024
-https\://maven.aliyun.com/nexus/content/groups/public/.error=
-https\://maven.aliyun.com/nexus/content/groups/public/.lastUpdated=1713764643383
-https\://maven.aliyun.com/repository/public/.error=
-https\://maven.aliyun.com/repository/public/.lastUpdated=1713764870394
-https\://packages.aliyun.com/maven/repository/2390498-release-I0JIZp/.lastUpdated=1713764643914
-https\://repo.maven.apache.org/maven2/.error=
-https\://repo.maven.apache.org/maven2/.lastUpdated=1714281315156

+ 0 - 1
configuration/.m2/repository/com/ziniao/ziniao-sdk-java/5.1.0/ziniao-sdk-java-5.1.0.jar.sha1

@@ -1 +0,0 @@
-8d3e5d93b366a0d813f22ac02ac13941951d1a51

+ 0 - 8
configuration/.m2/repository/com/ziniao/ziniao-sdk-java/5.1.0/ziniao-sdk-java-5.1.0.pom

@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>com.ziniao</groupId>
-  <artifactId>ziniao-sdk-java</artifactId>
-  <version>5.1.0</version>
-</project>

+ 0 - 9
configuration/.m2/repository/com/ziniao/ziniao-sdk-java/5.1.0/ziniao-sdk-java-5.1.0.pom.lastUpdated

@@ -1,9 +0,0 @@
-#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
-#Sun Apr 28 13:15:14 CST 2024
-https\://maven.aliyun.com/nexus/content/groups/public/.error=
-https\://maven.aliyun.com/nexus/content/groups/public/.lastUpdated=1713764632116
-https\://maven.aliyun.com/repository/public/.error=
-https\://maven.aliyun.com/repository/public/.lastUpdated=1713764870008
-https\://packages.aliyun.com/maven/repository/2390498-release-I0JIZp/.lastUpdated=1713764633065
-https\://repo.maven.apache.org/maven2/.error=
-https\://repo.maven.apache.org/maven2/.lastUpdated=1714281314312

+ 0 - 1
configuration/.m2/repository/com/ziniao/ziniao-sdk-java/5.1.0/ziniao-sdk-java-5.1.0.pom.sha1

@@ -1 +0,0 @@
-22b4de7d7dc2154785a6bc28443d278924e85c46

+ 0 - 0
configuration/.m2/repository/com/ziniao/ziniao-sdk-java/5.1.0/ziniao-sdk-java-5.1.0.jar → configuration/.m2/repository/ziniao-sdk-java-5.1.0.jar


+ 0 - 0
configuration/.m2/settings.xml → configuration/.m2/settings/settings(aliyun).xml


+ 34 - 0
configuration/.m2/settings/settings(nexus).xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
+
+  <localRepository>C:\Users\JT\.m2\repository</localRepository>
+
+  <mirrors>
+    <mirror>
+      <id>maven-public</id>             <!-- 仓库组名 -->
+      <mirrorOf>*</mirrorOf>            <!-- 镜像范围:全部 -->
+      <name>Nexus mine</name>
+      <url>http://localhost:8888/repository/maven-public/</url>
+    </mirror>
+  </mirrors>
+
+  <servers>
+    <server>
+      <id>maven-public</id>
+      <username>admin</username>
+      <password>123456</password>
+    </server>
+    <server>
+      <id>maven-snapshot</id>           <!-- 仓库名 -->
+      <username>admin</username>        <!-- 私服用户名 -->
+      <password>123456</password>       <!-- 私服密码 -->
+    </server>
+    <server>
+      <id>maven-releases</id>
+      <username>admin</username>
+      <password>123456</password>
+    </server>
+  </servers>
+
+</settings>

+ 17 - 0
configuration/.m2/settings/settings.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
+
+    <localRepository>C:\Users\JT\.m2\repository</localRepository>
+
+    <mirrors>
+        <mirror>
+            <id>mirror</id>
+            <mirrorOf>central,jcenter,!rdc-releases,!rdc-snapshots</mirrorOf>
+            <name>mirror</name>
+            <url>https://maven.aliyun.com/nexus/content/groups/public</url>
+        </mirror>
+    </mirrors>
+
+</settings>

+ 6 - 6
configuration/deploy-script.sh → configuration/backendsys.sh

@@ -4,17 +4,17 @@
 # sudo chown -R ubuntu:ubuntu /home/www/project/BackendSys
 
 # 增加可执行权限
-# chmod +x /home/www/project/BackendSys/target/deploy-script.sh
+# chmod +x /home/www/project/BackendSys/target/backendsys.sh
 # 启动应用程序
-# /home/www/project/BackendSys/target/deploy-script.sh start
+# /home/www/project/BackendSys/target/backendsys.sh start
 # 停止应用程序
-# /home/www/project/BackendSys/target/deploy-script.sh stop
+# /home/www/project/BackendSys/target/backendsys.sh stop
 # 重启应用程序
-# /home/www/project/BackendSys/target/deploy-script.sh restart
+# /home/www/project/BackendSys/target/backendsys.sh restart
 # 查看日志
 # tail -f /home/www/project/BackendSys/target/backendsys.log
 
-APP_JAR="/home/www/project/BackendSys/target/backendsys-1.0.0.jar"
+APP_JAR="/home/www/project/BackendSys/target/backendsys.jar"
 LOG_FILE="/home/www/project/BackendSys/target/backendsys.log"
 
 start() {
@@ -23,7 +23,7 @@ start() {
 }
 
 stop() {
-    ID=`ps -ef | grep "backendsys-1.0.0.jar" | grep -v "grep" | awk '{print $2}'`
+    ID=`ps -ef | grep "backendsys.jar" | grep -v "grep" | awk '{print $2}'`
     echo $ID
 
     for id in $ID

+ 1 - 1
configuration/webhook.sh

@@ -30,7 +30,7 @@ chmod +x ./system_config/deploy-script.sh
 # 监听控制台
 # tail -f ./target/backendsys.log
 
-## 在 deploy-script.sh 中
+## 在 backendsys.sh 中
 #echo "Current directory: $(pwd)"
 ## 打印环境变量
 #env

+ 15 - 33
pom.xml

@@ -6,21 +6,19 @@
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>3.1.1</version>
-        <relativePath/> <!-- lookup parent from repository -->
     </parent>
     <groupId>com.backendsys</groupId>
     <artifactId>backendsys</artifactId>
     <version>1.0.0</version>
     <name>backendsys</name>
     <properties>
-        <java.version>17</java.version>
-        <activiti.version>7.0.0.SR1</activiti.version>
-        <activiti.cloud.version>7.0.0.Beta1</activiti.cloud.version>
+        <java.version>19</java.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>
 
     <dependencies>
 
-        <!-- spring-web -->
+        <!-- Spring Web -->
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
@@ -31,12 +29,9 @@
                     <artifactId>snakeyaml</artifactId>
                 </exclusion>
             </exclusions>
-            <!-- -->
         </dependency>
 
-
-        <!-- Nacos 配置中心 -->
-
+        <!-- Nacos -->
 
         <!-- logback / log4j / slf4j -->
         <dependency>
@@ -58,7 +53,7 @@
             <version>2.0</version>
         </dependency>
 
-        <!-- spring-security -->
+        <!-- Security -->
         <dependency>
             <groupId>org.springframework.security</groupId>
             <artifactId>spring-security-oauth2-authorization-server</artifactId>
@@ -72,14 +67,13 @@
             <version>2.3.3</version>
         </dependency>
 
-        <!-- https://hutool.cn -->
+        <!-- Hutool -->
         <dependency>
             <groupId>cn.hutool</groupId>
             <artifactId>hutool-all</artifactId>
             <version>5.8.20</version>
         </dependency>
 
-
         <!-- fastJSON解析库 -->
         <dependency>
             <groupId>com.alibaba</groupId>
@@ -216,8 +210,6 @@
             <version>4.5.0</version>
         </dependency>
 
-
-
         <!-- 阿里云 OSS -->
         <dependency>
             <groupId>com.aliyun.oss</groupId>
@@ -290,7 +282,6 @@
 <!--            <version>1.0.150</version>-->
 <!--        </dependency>-->
 
-
         <!--Java 9及以上的版本,则需要添加jaxb相关依赖-->
         <dependency>
             <groupId>javax.xml.bind</groupId>
@@ -326,8 +317,7 @@
             <version>3.23.5</version>
         </dependency>
 
-        <!-- 引用 紫鸟JavaSDK (上传阿里云 Maven 私有仓库)-->
-        <!-- https://packages.aliyun.com/repos/2390498-release-I0JIZp/packages -->
+        <!-- 紫鸟科技SDK (私有库)-->
         <dependency>
             <groupId>com.ziniao</groupId>
             <artifactId>ziniao-sdk-java</artifactId>
@@ -341,7 +331,6 @@
 <!--            <systemPath>${project.basedir}/libs/ziniao-sdk-java-5.1.0.jar</systemPath>-->
 <!--        </dependency>-->
 
-
         <!-- 火山AI SDK 测试-->
 <!--        <dependency>-->
 <!--            <groupId>com.volcengine</groupId>-->
@@ -378,17 +367,6 @@
 <!--        </dependency>-->
 
 
-
-        <!-- Thymeleaf模板引擎 -->
-        <!--<dependency>-->
-        <!--    <groupId>org.springframework.boot</groupId>-->
-        <!--    <artifactId>spring-boot-starter-thymeleaf</artifactId>-->
-        <!--</dependency>-->
-        <!--<dependency>-->
-        <!--    <groupId>org.thymeleaf.extras</groupId>-->
-        <!--    <artifactId>thymeleaf-extras-springsecurity6</artifactId>-->
-        <!--</dependency>-->
-
 <!--        <dependency>-->
 <!--            <groupId>org.springframework.boot</groupId>-->
 <!--            <artifactId>spring-boot-starter-test</artifactId>-->
@@ -400,6 +378,7 @@
 <!--            <scope>test</scope>-->
 <!--        </dependency>-->
 
+        <!-- Swagger -->
         <dependency>
             <groupId>org.springdoc</groupId>
             <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
@@ -409,6 +388,7 @@
     </dependencies>
 
 
+
     <profiles>
         <profile>
             <id>local</id>
@@ -429,6 +409,7 @@
 
 
     <build>
+        <finalName>${project.artifactId}</finalName>
         <resources>
             <!-- 扫描src/main/java下所有xx.xml文件 -->
             <resource>
@@ -465,14 +446,15 @@
 
 
         <plugins>
+
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
                     <parameters>true</parameters>
-                    <source>17</source>
-                    <target>17</target>
-                    <encoding>UTF-8</encoding>
+                    <source>${java.version}</source>
+                    <target>${java.version}</target>
+                    <encoding>${project.build.sourceEncoding}</encoding>
                 </configuration>
             </plugin>
 
@@ -519,7 +501,7 @@
 <!--                        </goals>-->
 <!--                        <configuration>-->
 <!--                            &lt;!&ndash; <outputDirectory>${project.build.directory}/lib</outputDirectory> &ndash;&gt;-->
-<!--                            <outputDirectory>${project.basedir}/libs</outputDirectory>-->
+<!--                            <outputDirectory>libs</outputDirectory>-->
 <!--                        </configuration>-->
 <!--                    </execution>-->
 <!--                </executions>-->