当前位置:   article > 正文

springboot+xjar加密打包部署教程_jar加密部署

jar加密部署

需求背景

为了跟上时代的步伐,为了更好的生存。开个玩笑,就是心血来潮,使用xjar加密部署jar包,于是就测试一下。

xjar教程

1-maven配置文件修改

首先找到自己ideal配置的maven文件夹,然后找到apache-maven-3.9.3\conf\settings.xml

  1. // 如果配置了aliyun或者其他的仓库就需要添加【,!jitpack.io】
  2. // 如果没有配置,直接忽略
  3. <mirrors>
  4. <mirror>
  5. <id>maven-default-http-blocker</id>
  6. <mirrorOf>external:http:*,!jitpack.io</mirrorOf>
  7. <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
  8. <url>http://0.0.0.0/</url>
  9. <blocked>true</blocked>
  10. </mirror>
  11. </mirrors>

2-pom文件修改

打开自己的maven项目,然后修改pom文件

  1. <!-- 增加xjar依赖仓库 -->
  2. <pluginRepositories>
  3. <pluginRepository>
  4. <id>jitpack.io</id>
  5. <url>https://jitpack.io</url>
  6. </pluginRepository>
  7. </pluginRepositories>
  8. <build>
  9. <plugins>
  10. <!-- 如果还有其他的plugin,继续在后面追加下面的xjar即可 -->
  11. <!-- xjar插件开始 -->
  12. <plugin>
  13. <groupId>com.github.core-lib</groupId>
  14. <artifactId>xjar-maven-plugin</artifactId>
  15. <version>4.0.2</version>
  16. <executions>
  17. <execution>
  18. <id>xjar</id>
  19. <phase>package</phase>
  20. <goals>
  21. <goal>build</goal>
  22. </goals>
  23. </execution>
  24. </executions>
  25. <configuration>
  26. <targetJar>${project.artifactId}-xjar.jar</targetJar>
  27. <!-- excludes配置节,不对哪些文件进行加密-->
  28. <excludes>
  29. <exclude>
  30. static/**
  31. </exclude>
  32. <exclude>
  33. templates/**
  34. </exclude>
  35. </excludes>
  36. </configuration>
  37. </plugin>
  38. <!-- xjar插件结束 -->
  39. </plugins>
  40. </build>

 修改了pom文件后,点击重新编译按钮。

 3-maven打包

然后点击maven窗口的播放按钮进行命令打包。

  1. # 打包命令,123456换成自己的密码
  2. mvn clean package -Dxjar.password=123456

 这个命令执行完,会在target文件夹下面生成打包后的jar文件和xjar.go两个文件。注意新生成的jar文件比之前不加密生成的jar文件要大好多,我这边是2.56倍。然后把这两个文件上传到服务器上。

4-go环境部署

  1. // go下载官网
  2. https://studygolang.com/dl

 然后把文件上传到centos服务器上。

  1. // 没有文件夹就自己创建,然后把下载的go1.22.0.linux-amd64.tar.gz文件上传到这个文件夹下
  2. cd /opt/xjar
  3. tar -zxvf go1.22.0.linux-amd64.tar.gz
  4. vim /etc/profile回车
  5. // 在文件的最后追加go地址
  6. export PATH=$PATH:/opt/xjar/go/bin
  7. // 然后按esc键,在输入:wq 退出
  8. // 输入刷新配置命令
  9. source /etc/profile
  10. // 输入go版本查询命令
  11. go version
  12. // 如果出现版本信息,说明安装成功

5-启动脚本

 

  1. -- 新建run-go.sh,内容如下。
  2. -- xjar.go就是刚才maven的命令编译生成的。
  3. -- 启动的时候需要先执行这个命令,这个命令执行完会生成xjar文件
  4. go build xjar.go
  5. -- 新建run-xjar.sh,内容如下
  6. -- 这个命令是通过xjar启动加密后的jar包
  7. -- 注意事项,xjar -java -jar 后面必须跟jar文件所在的地址
  8. -- 其余的配置信息在.jar文件的后面,需要注意先后顺序
  9. nohup /opt/aiot/xjar java -jar /opt/aiot/aiot-xjar.jar -Xms1024m -Xmx1024m -XX:PermSize=256m --spring.profiles.acive=dev >> /dev/null 2>&1 &

结束

-----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----

-----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----

-----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----

  1. package cn.renkai721.bean.vo;
  2. import lombok.extern.slf4j.Slf4j;
  3. @Slf4j
  4. public class MakeUpTheWordCount {
  5. private String make_up_the_word_count_column_999999999_1;
  6. private String make_up_the_word_count_column_999999999_2;
  7. private String make_up_the_word_count_column_999999999_3;
  8. private String make_up_the_word_count_column_999999999_4;
  9. private String make_up_the_word_count_column_999999999_5;
  10. private String make_up_the_word_count_column_999999999_6;
  11. private String make_up_the_word_count_column_999999999_7;
  12. private String make_up_the_word_count_column_999999999_8;
  13. private String make_up_the_word_count_column_999999999_9;
  14. private String make_up_the_word_count_column_999999999_10;
  15. private String make_up_the_word_count_column_999999999_11;
  16. private String make_up_the_word_count_column_999999999_12;
  17. private String make_up_the_word_count_column_999999999_13;
  18. private String make_up_the_word_count_column_999999999_14;
  19. private String make_up_the_word_count_column_999999999_15;
  20. private String make_up_the_word_count_column_999999999_16;
  21. private String make_up_the_word_count_column_999999999_17;
  22. private String make_up_the_word_count_column_999999999_18;
  23. private String make_up_the_word_count_column_999999999_19;
  24. private String make_up_the_word_count_column_999999999_20;
  25. public String getMake_up_the_word_count_column_999999999_1() {
  26. return make_up_the_word_count_column_999999999_1;
  27. }
  28. public void setMake_up_the_word_count_column_999999999_1(String make_up_the_word_count_column_999999999_1) {
  29. this.make_up_the_word_count_column_999999999_1 = make_up_the_word_count_column_999999999_1;
  30. }
  31. public String getMake_up_the_word_count_column_999999999_2() {
  32. return make_up_the_word_count_column_999999999_2;
  33. }
  34. public void setMake_up_the_word_count_column_999999999_2(String make_up_the_word_count_column_999999999_2) {
  35. this.make_up_the_word_count_column_999999999_2 = make_up_the_word_count_column_999999999_2;
  36. }
  37. public String getMake_up_the_word_count_column_999999999_3() {
  38. return make_up_the_word_count_column_999999999_3;
  39. }
  40. public void setMake_up_the_word_count_column_999999999_3(String make_up_the_word_count_column_999999999_3) {
  41. this.make_up_the_word_count_column_999999999_3 = make_up_the_word_count_column_999999999_3;
  42. }
  43. public String getMake_up_the_word_count_column_999999999_4() {
  44. return make_up_the_word_count_column_999999999_4;
  45. }
  46. public void setMake_up_the_word_count_column_999999999_4(String make_up_the_word_count_column_999999999_4) {
  47. this.make_up_the_word_count_column_999999999_4 = make_up_the_word_count_column_999999999_4;
  48. }
  49. public String getMake_up_the_word_count_column_999999999_5() {
  50. return make_up_the_word_count_column_999999999_5;
  51. }
  52. public void setMake_up_the_word_count_column_999999999_5(String make_up_the_word_count_column_999999999_5) {
  53. this.make_up_the_word_count_column_999999999_5 = make_up_the_word_count_column_999999999_5;
  54. }
  55. public String getMake_up_the_word_count_column_999999999_6() {
  56. return make_up_the_word_count_column_999999999_6;
  57. }
  58. public void setMake_up_the_word_count_column_999999999_6(String make_up_the_word_count_column_999999999_6) {
  59. this.make_up_the_word_count_column_999999999_6 = make_up_the_word_count_column_999999999_6;
  60. }
  61. public String getMake_up_the_word_count_column_999999999_7() {
  62. return make_up_the_word_count_column_999999999_7;
  63. }
  64. public void setMake_up_the_word_count_column_999999999_7(String make_up_the_word_count_column_999999999_7) {
  65. this.make_up_the_word_count_column_999999999_7 = make_up_the_word_count_column_999999999_7;
  66. }
  67. public String getMake_up_the_word_count_column_999999999_8() {
  68. return make_up_the_word_count_column_999999999_8;
  69. }
  70. public void setMake_up_the_word_count_column_999999999_8(String make_up_the_word_count_column_999999999_8) {
  71. this.make_up_the_word_count_column_999999999_8 = make_up_the_word_count_column_999999999_8;
  72. }
  73. public String getMake_up_the_word_count_column_999999999_9() {
  74. return make_up_the_word_count_column_999999999_9;
  75. }
  76. public void setMake_up_the_word_count_column_999999999_9(String make_up_the_word_count_column_999999999_9) {
  77. this.make_up_the_word_count_column_999999999_9 = make_up_the_word_count_column_999999999_9;
  78. }
  79. public String getMake_up_the_word_count_column_999999999_10() {
  80. return make_up_the_word_count_column_999999999_10;
  81. }
  82. public void setMake_up_the_word_count_column_999999999_10(String make_up_the_word_count_column_999999999_10) {
  83. this.make_up_the_word_count_column_999999999_10 = make_up_the_word_count_column_999999999_10;
  84. }
  85. public String getMake_up_the_word_count_column_999999999_11() {
  86. return make_up_the_word_count_column_999999999_11;
  87. }
  88. public void setMake_up_the_word_count_column_999999999_11(String make_up_the_word_count_column_999999999_11) {
  89. this.make_up_the_word_count_column_999999999_11 = make_up_the_word_count_column_999999999_11;
  90. }
  91. public String getMake_up_the_word_count_column_999999999_12() {
  92. return make_up_the_word_count_column_999999999_12;
  93. }
  94. public void setMake_up_the_word_count_column_999999999_12(String make_up_the_word_count_column_999999999_12) {
  95. this.make_up_the_word_count_column_999999999_12 = make_up_the_word_count_column_999999999_12;
  96. }
  97. public String getMake_up_the_word_count_column_999999999_13() {
  98. return make_up_the_word_count_column_999999999_13;
  99. }
  100. public void setMake_up_the_word_count_column_999999999_13(String make_up_the_word_count_column_999999999_13) {
  101. this.make_up_the_word_count_column_999999999_13 = make_up_the_word_count_column_999999999_13;
  102. }
  103. public String getMake_up_the_word_count_column_999999999_14() {
  104. return make_up_the_word_count_column_999999999_14;
  105. }
  106. public void setMake_up_the_word_count_column_999999999_14(String make_up_the_word_count_column_999999999_14) {
  107. this.make_up_the_word_count_column_999999999_14 = make_up_the_word_count_column_999999999_14;
  108. }
  109. public String getMake_up_the_word_count_column_999999999_15() {
  110. return make_up_the_word_count_column_999999999_15;
  111. }
  112. public void setMake_up_the_word_count_column_999999999_15(String make_up_the_word_count_column_999999999_15) {
  113. this.make_up_the_word_count_column_999999999_15 = make_up_the_word_count_column_999999999_15;
  114. }
  115. public String getMake_up_the_word_count_column_999999999_16() {
  116. return make_up_the_word_count_column_999999999_16;
  117. }
  118. public void setMake_up_the_word_count_column_999999999_16(String make_up_the_word_count_column_999999999_16) {
  119. this.make_up_the_word_count_column_999999999_16 = make_up_the_word_count_column_999999999_16;
  120. }
  121. public String getMake_up_the_word_count_column_999999999_17() {
  122. return make_up_the_word_count_column_999999999_17;
  123. }
  124. public void setMake_up_the_word_count_column_999999999_17(String make_up_the_word_count_column_999999999_17) {
  125. this.make_up_the_word_count_column_999999999_17 = make_up_the_word_count_column_999999999_17;
  126. }
  127. public String getMake_up_the_word_count_column_999999999_18() {
  128. return make_up_the_word_count_column_999999999_18;
  129. }
  130. public void setMake_up_the_word_count_column_999999999_18(String make_up_the_word_count_column_999999999_18) {
  131. this.make_up_the_word_count_column_999999999_18 = make_up_the_word_count_column_999999999_18;
  132. }
  133. public String getMake_up_the_word_count_column_999999999_19() {
  134. return make_up_the_word_count_column_999999999_19;
  135. }
  136. public void setMake_up_the_word_count_column_999999999_19(String make_up_the_word_count_column_999999999_19) {
  137. this.make_up_the_word_count_column_999999999_19 = make_up_the_word_count_column_999999999_19;
  138. }
  139. public String getMake_up_the_word_count_column_999999999_20() {
  140. return make_up_the_word_count_column_999999999_20;
  141. }
  142. public void setMake_up_the_word_count_column_999999999_20(String make_up_the_word_count_column_999999999_20) {
  143. this.make_up_the_word_count_column_999999999_20 = make_up_the_word_count_column_999999999_20;
  144. }
  145. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/810141
推荐阅读
相关标签
  

闽ICP备14008679号