当前位置:   article > 正文

Springboot 代码混淆_springboot execution模糊类名

springboot execution模糊类名

pom.xml中添加

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>com.github.wvengen</groupId>
  5. <artifactId>proguard-maven-plugin</artifactId>
  6. <executions>
  7. <execution>
  8. <phase>package</phase>
  9. <goals><goal>proguard</goal></goals>
  10. </execution>
  11. </executions>
  12. <configuration>
  13. <proguardVersion>5.3.3</proguardVersion>
  14. <injar>${project.build.finalName}.jar</injar>
  15. <outjar>${project.build.finalName}.jar</outjar>
  16. <obfuscate>true</obfuscate>
  17. <proguardInclude>${project.basedir}/proguard.cfg</proguardInclude>
  18. <libs>
  19. <!-- Include main JAVA library required.-->
  20. <lib>${java.home}/lib/rt.jar</lib>
  21. <!-- Include crypto JAVA library if necessary.-->
  22. <lib>${java.home}/lib/jce.jar</lib>
  23. </libs>
  24. </configuration>
  25. <dependencies>
  26. <dependency>
  27. <groupId>net.sf.proguard</groupId>
  28. <artifactId>proguard-base</artifactId>
  29. <version>5.3.3</version>
  30. </dependency>
  31. </dependencies>
  32. </plugin>
  33. <plugin>
  34. <groupId>org.springframework.boot</groupId>
  35. <artifactId>spring-boot-maven-plugin</artifactId>
  36. <executions>
  37. <execution>
  38. <goals>
  39. <goal>repackage</goal>
  40. </goals>
  41. <configuration>
  42. <mainClass>com.example.Application</mainClass>
  43. </configuration>
  44. </execution>
  45. </executions>
  46. </plugin>
  47. </plugins>
  48. </build>

pom.xml同级目录下创建proguard.cfg文件

  1. -target 1.8 ##指定java版本号
  2. -dontshrink ##默认是开启的,这里关闭shrink,即不删除没有使用的类/成员
  3. -dontoptimize ##默认是开启的,这里关闭字节码级别的优化
  4. -useuniqueclassmembernames ##对于类成员的命名的混淆采取唯一策略
  5. -adaptclassstrings ## 混淆类名之后,对使用Class.forName('className')之类的地方进行相应替代
  6. -dontusemixedcaseclassnames ## 混淆时不生成大小写混合的类名,默认是可以大小写混合
  7. ##对异常、注解信息在runtime予以保留,不然影响springboot启动
  8. -keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
  9. ##保留main方法的类及其方法名
  10. -keepclasseswithmembers public class * { public static void main(java.lang.String[]);}
  11. -keepclassmembers enum * { *; } ##保留枚举成员及方法
  12. ## 保持对外的接口性质类对外的类名与方法名不变
  13. #-keep class com.example.common.sort.exact.bean.**
  14. -keep class com.example.config.**
  15. -keep class com.example.config.** { *; }
  16. ##---------------Begin: proguard configuration for Gson ----------
  17. # Gson uses generic type information stored in a class file when working with fields. Proguard
  18. # removes such information by default, so configure it to keep all of it.
  19. -keepattributes Signature
  20. # Gson specific classes
  21. -keep class sun.misc.Unsafe { *; }
  22. #-keep class com.google.gson.stream.** { *; }
  23. # Application classes that will be serialized/deserialized over Gson
  24. #-keep class com.google.gson.examples.android.model.** { *; } ##这里需要改成解析到哪个 javabean
  25. -keep class com.google.**{*;}
  26. -keepclassmembers class * implements java.io.Serializable {
  27. static final long serialVersionUID;
  28. private static final java.io.ObjectStreamField[] serialPersistentFields;
  29. private void writeObject(java.io.ObjectOutputStream);
  30. private void readObject(java.io.ObjectInputStream);
  31. java.lang.Object writeReplace();
  32. java.lang.Object readResolve();
  33. }
  34. ##---------------End: proguard configuration for Gson ----------



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

闽ICP备14008679号