打包配置
注意必须配置repackage
配置项
<build>
<finalName>打包的jar包名称,可以使用${参数名}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
打包依赖外部的jar包
<dependency>
<groupId>com.xxx.xx</groupId>
<artifactId>xxx-xxx</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/xxx.jar</systemPath>
</dependency>
groupId, artifactId 随意写但是必须要唯一,systemPath: 指向外部依赖的jar文件绝对路径
Linux后台运行SpringBoot打包的jar程序启动命令,JVM参数可调
nohup java \
-jar \
-server \
-XX:MetaspaceSize=128m \
-XX:MaxMetaspaceSize=128m \
-Xms1024m \
-Xmx1024m \
-Xmn256m \
-Xss256k \
-XX:SurvivorRatio=8 \
-XX:+UseConcMarkSweepGC \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath=/root/work/payment-heapDump.hprof \
-Djava.security.egd=file:/dev/./urandom \
./xxx.jar --spring.profiles.active=dev > /dev/null 2>&1 &
nohup java
-Xms8192M \
-Xmx8192M \
-Xss10240k \
-XX:Newsize=1024M \
-XX:MaxNewSize=6144M \
-Dcom.sunmanagement.jmxremote \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.port=24056 \
-Dcom.sun.management.jmxremote.ssl=false \
-XX:+UseBiasedLocking \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath=/home/app/logs \
-Duser.timezone=GMT+8 \
-Djava.awt.headless=true \
-Djava.security.egd=file:/dev/../dev/urandom \
-Djava.io.tmpdir=$path \
-Dlog4j.configurationFile=../conf/1og4j2.xml \
-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncloggerContextSelector \
-jar ../lib/app.1.8.3.0.7.jar > /dev/null 2>&1 &
Gradle 打包编译打包命令
# clean: 清理编译文件
# build:编译文件
# --debug:以debug模式执行命令,可以打印出更详细的日志
# -x test:跳过单元测试
gradle clean build --debug -x test