目录
1、 下载 allatori.jar 和 allatori-annotations.jar
GitHub地址:https://github.com/Lovnx/confusion
1、 下载 allatori.jar 和 allatori-annotations.jar
将lib文件夹(文件夹内包含上面步骤的两个jar包)放入项目路径中
2、创建 allatori.xml 文件
<config>
<input>
<jar in="../target/XXXX-1.0-SNAPSHOT.jar" out="../target/XXXX-1.0-SNAPSHOT-obfuscated.jar"/>
</input>
<keep-names>
<class access="protected+">
<field access="protected+"/>
<method access="protected+"/>
</class>
</keep-names>
<property name="log-file" value="../target/log.xml"/>
<ignore-classes>
<class template="class *springframework*" />
<class template="class *shardingjdbc*" />
<class template="class *jni*" />
<class template="class *alibaba*"/>
<class template="class *persistence*"/>
<!-- 排除如下包下的类-->
<!-- jpa Dao层-->
<class template="class com.XXX.dao.*" />
<!-- jpa 实体类-->
<class template="class com.XXX.entity.*" />
</ignore-classes>
</config>
3、在pom.xml中加入一下内容
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</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}/lib/allatori.xml</argument>
</arguments>
</configuration>
</plugin>
<!-- Allatori plugin end -->
</plugins>
</build>
4、打包
1、clean maven工程。
2、install package 工程,看到如下信息后表示成功:
################################################
# #
# ## # # ## ### ### ## ### #
# # # # # # # # # # # # # #
# ### # # ### # # # ## # #
# # # ### ### # # # ### # # ### #
# #
# DEMO VERSION! #
# NOT FOR COMMERCIAL USE! #
# #
# Demo version adds System.out's #
# and gives 'ALLATORI_DEMO' name #
# to some fields and methods. #
# #
# #
# Obfuscation by Allatori Obfuscator v6.4 DEMO #
# #
# http://www.allatori.com #
# #
################################################
XXXX-1.0-SNAPSHOT-obfuscated.jar 即是我们需要的包