1、下載maven加密插件
pom文件加入以下配置
<!-- 設置 jitpack.io 插件倉庫 -->
<pluginRepositories>
<pluginRepository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</pluginRepository>
</pluginRepositories>
<plugin>
<groupId>com.github.core-lib</groupId>
<artifactId>xjar-maven-plugin</artifactId>
<version>2.0.9</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
<configuration>
<!-- 加密的密碼 -->
<password>password</password>
<!-- optional
<algorithm/>
<keySize/>
<ivSize/>
<mode/>
<includes>
<include/>
</includes>
<excludes>
<exclude/>
</excludes>
<sourceDir/>
<sourceJar/>
<targetDir/>
<targetJar/>
-->
<!-- 加密後生成的jar-->
<targetJar>xstm-management.jar</targetJar>
</configuration>
</execution>
</executions>
</plugin>
然後執行 clean install
啓動
nohup java -jar /home/stm/jar/xstm-management.jar --xjar.keyfile=/home/stm/jar/stm.key > /home/stm/jar/stm-management.log &
stm.key 的內容
password: password
algorithm: AES
keysize: 128
ivsize: 128
hold: false
hlod爲false,啓動後會刪除stm.key文件。