http://www.allatori.com/doc.html
https://blog.csdn.net/rickiyeat/article/details/79386000
https://blog.csdn.net/u014795242/article/details/81204574
https://github.com/Lovnx/confusion
https://www.jianshu.com/p/9df4a0bb46be
jar包可以在https://github.com/Lovnx/confusion
这个示例中得到
<build>
<finalName>${finalName}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>你的启动类</mainClass>
<includeSystemScope>true</includeSystemScope>
<fork>true</fork>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Allatori plugin start -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-and-filter-allatori-config</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target</outputDirectory>
<resources>
<resource>
<directory>${basedir}/allatori</directory>
<includes>
<include>allatori.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>run-allatori</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Xms128m</argument>
<argument>-Xmx512m</argument>
<argument>-jar</argument>
<argument>${basedir}/lib/allatori.jar</argument>
<argument>${basedir}/target/allatori.xml</argument>
</arguments>
</configuration>
</plugin>
<!-- Allatori plugin end -->
</plugins>
</build>
<config>
<input>
<!-- in中是待混淆的jar包,out是混淆后的jar包,路径是相对本配置文件所在位置 -->
<!-- 这个示例中,A.jar是工程jar包,B.jar是子模块jar包 -->
<jar in="A.jar" out="A-obfuscated.jar"/>
<jar in="../../B/target/B.jar" out="B.jar"/>
</input>
<!-- ignore-classes中配置不被混淆的类 -->
<ignore-classes>
<!-- 配置了启动相关类不被混淆,保证springboot可以正常启动 -->
<class template="class 启动类"/>
<class template="class *springframework*"/>
<class template="class *alibaba*"/>
<class template="class *persistence*"/>
<class template="class *apache*"/>
<class template="class *model*"/>
<class template="class *enums*"/>
<class template="class *repository*"/>
</ignore-classes>
<keep-names>
<!-- 防止部分类、方法、变量找不到名称而报错 -->
<!-- 所有方法名称不变,parameters="keep"表示方法参数名也不变 -->
<method template="*(**)" parameters="keep"/>
<!-- com.a.b.c中的类以及其子包中的类的名称不变 -->
<class template="class com.a.b.c.*"/>
</keep-names>
<!-- 混淆前后的映射关系保存在log.xml中 -->
<property name="log-file" value="log.xml"/>
</config>
更多配置请参考官方文档:http://www.allatori.com/doc.html
压缩软件我用的是Winrar,这里的压缩方式选择的是存储
至此,混淆完成
java -jar A-obfuscated.jar
以上是根据自己的项目和网上的博客以及官方文档一步步摸索出来的,如有错误,请不吝指正!
手机扫一扫
移动阅读更方便
你可能感兴趣的文章