diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index a0cb8a857..2299b0c12 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -65,21 +65,21 @@ <build> <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>2.1.1.RELEASE</version> - <configuration> - <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 --> - </configuration> - <executions> - <execution> - <goals> - <goal>repackage</goal> - </goals> - </execution> - </executions> - </plugin> +<!-- <plugin>--> +<!-- <groupId>org.springframework.boot</groupId>--> +<!-- <artifactId>spring-boot-maven-plugin</artifactId>--> +<!-- <version>2.1.1.RELEASE</version>--> +<!-- <configuration>--> +<!-- <fork>true</fork> <!– 如果没有该配置,devtools不会生效 –>--> +<!-- </configuration>--> +<!-- <executions>--> +<!-- <execution>--> +<!-- <goals>--> +<!-- <goal>repackage</goal>--> +<!-- </goals>--> +<!-- </execution>--> +<!-- </executions>--> +<!-- </plugin>--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> @@ -88,7 +88,62 @@ <failOnMissingWebXml>false</failOnMissingWebXml> <warName>${project.artifactId}</warName> </configuration> - </plugin> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>3.0.2</version> + <configuration> + <excludes> + <exclude>*.yml</exclude> + <exclude>logback.xml</exclude> + </excludes> + <archive> + <!-- 生成的jar中,不要包含pom.xml和pom.properties这两个文件 --> + <addMavenDescriptor>false</addMavenDescriptor> + <manifest> + <!-- 是否要把第三方jar放到manifest的classpath中 --> + <addClasspath>true</addClasspath> + <!-- 外部依赖jar包的最终位置 --> + <classpathPrefix>lib/</classpathPrefix> + <!-- 项目启动类 --> + <mainClass>com.ruoyi.RuoYiApplication</mainClass> + </manifest> + </archive> + </configuration> + </plugin> + + <!-- 使用assembly打包 --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>3.3.0</version> + <configuration> + <descriptors> + <!-- assembly配置文件位置 --> + <descriptor>src/main/assembly/assembly.xml</descriptor> + </descriptors> + </configuration> + <executions> + <execution> + <id>make-assembly</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + <!-- 打包发布时,跳过单元测试 --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.22.0</version> + <configuration> + <skipTests>true</skipTests> + </configuration> + </plugin> </plugins> <finalName>${project.artifactId}</finalName> </build> diff --git a/ruoyi-admin/src/main/assembly/assembly.xml b/ruoyi-admin/src/main/assembly/assembly.xml new file mode 100644 index 000000000..a12c867c3 --- /dev/null +++ b/ruoyi-admin/src/main/assembly/assembly.xml @@ -0,0 +1,71 @@ +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> + + <!-- + 必须写,否则打包时会有 assembly ID must be present and non-empty 错误 + 这个名字最终会追加到打包的名字的末尾,如项目的名字为 speed-api-0.0.1-SNAPSHOT, + 则最终生成的包名为 speed-api-0.0.1-SNAPSHOT-bin.zip + --> + <id>bin</id> + + <baseDirectory>RuoYi-Vue-${project.version}</baseDirectory> + + <!-- 打包后的文件格式,可以是zip,tar,tar.gz,tar.bz2,jar,war,dir --> + <formats> + <format>zip</format> + </formats> + + <!-- 压缩包下是否生成和项目名相同的根目录 --> + <includeBaseDirectory>false</includeBaseDirectory> + + <dependencySets> + <dependencySet> + <!-- 不使用项目的artifact,第三方jar不要解压,打包进zip文件的lib目录 --> + <useProjectArtifact>false</useProjectArtifact> + <outputDirectory>lib</outputDirectory> + <unpack>false</unpack> + </dependencySet> + </dependencySets> + + <fileSets> + <!-- 把项目相关的说明文件,打包进zip文件的根目录 --> + <fileSet> + <directory>${project.basedir}</directory> + <outputDirectory></outputDirectory> + <includes> + <include>README*</include> + <include>LICENSE*</include> + <include>NOTICE*</include> + </includes> + </fileSet> + + <!-- 把项目的配置文件,打包进zip文件的config目录 --> + <fileSet> + <directory>${project.basedir}/src/main/resources</directory> + <outputDirectory>config</outputDirectory> + <includes> + <include>*.yml</include> + <include>logback.xml</include> + </includes> + </fileSet> + + <!-- 把项目的脚本文件,打包进zip文件的bin目录 --> + <fileSet> + <directory>${project.basedir}/src/main/bin</directory> + <outputDirectory>bin</outputDirectory> + <fileMode>755</fileMode> + <directoryMode>755</directoryMode> + <lineEnding>unix</lineEnding> + </fileSet> + + <!-- 把项目自己编译出来的jar文件,打包进zip文件的根目录 --> + <fileSet> + <directory>${project.build.directory}</directory> + <outputDirectory></outputDirectory> + <includes> + <include>*.jar</include> + </includes> + </fileSet> + </fileSets> +</assembly> \ No newline at end of file diff --git a/ruoyi-admin/src/main/bin/ry.sh b/ruoyi-admin/src/main/bin/ry.sh new file mode 100644 index 000000000..16574e72f --- /dev/null +++ b/ruoyi-admin/src/main/bin/ry.sh @@ -0,0 +1,91 @@ +#!/bin/sh +# author ruoyi +# ./ry.sh start 启动 +# ./ry.sh stop 停止 +# ./ry.sh restart 重启 +# ./ry.sh status 状态 +cd .. +AppName=ruoyi-admin.jar + +# JVM参数 +JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" +APP_HOME=`pwd` +LOG_PATH=$APP_HOME/logs/$AppName.log + +if [ "$1" = "" ]; +then + echo -e "\033[0;31m 未输入操作名 \033[0m \033[0;34m {start|stop|restart|status} \033[0m" + exit 1 +fi + +if [ "$AppName" = "" ]; +then + echo -e "\033[0;31m 未输入应用名 \033[0m" + exit 1 +fi + +function start() +{ + PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'` + + if [ x"$PID" != x"" ]; then + echo "$AppName is running..." + else + nohup java -jar $JVM_OPTS $APP_HOME/$AppName --logging.config=$APP_HOME/config/logback.xml > /dev/null 2>&1 & + echo "Start $AppName success..." + fi +} + +function stop() +{ + echo "Stop $AppName" + + PID="" + query(){ + PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'` + } + + query + if [ x"$PID" != x"" ]; then + kill -TERM $PID + echo "$AppName (pid:$PID) exiting..." + while [ x"$PID" != x"" ] + do + sleep 1 + query + done + echo "$AppName exited." + else + echo "$AppName already stopped." + fi +} + +function restart() +{ + stop + sleep 2 + start +} + +function status() +{ + PID=`ps -ef |grep java|grep $AppName|grep -v grep|wc -l` + if [ $PID != 0 ];then + echo "$AppName is running..." + else + echo "$AppName is not running..." + fi +} + +case $1 in + start) + start;; + stop) + stop;; + restart) + restart;; + status) + status;; + *) + +esac