方式一
1. 下载demo版的:官方版本
2. 把jar拷贝到项目中并创建xml如图:
3. 配置xml
- <?xml version="1.0" encoding="UTF-8"?>
- <config>
- <input>
- <!-- 这里的in表示需要混淆的jar(springboot打包后的jar),out表示输出混淆后的jar(混淆器修改springboot打包后的jar) -->
- <jar in="nacea-polling-1.0-SNAPSHOT.jar" out="nacea-polling-1.0-SNAPSHOT-obfuscated.jar" />
- </input>
- <keep-names>
- <class access="protected+">
- <field access="protected+" />
- <method access="protected+" />
- </class>
- </keep-names>
- <!-- 忽略springBoot的启动项(防止启动报错) -->
- <ignore-classes>
- <class template="class *springframework*" />
- <class template="class com.cxy.nacea.polling.entity.*" />
- <class template="class com.cxy.nacea.polling.entity.task.*" />
- </ignore-classes>
- <property name="log-file" value="log.xml" />
- <!-- 添加水印密匙,主要用来保护版权 -->
- <!-- <watermark key="secure-key-to-extract-watermark" value="Customer: John Smith; Date: xx.yy.zzzz"/> -->
- <!-- 配置过期时间 -->
- <!-- <expiry date="2000/01/01" string="EXPIRED!"/> -->
- </config>
4. 配置pom
- <!-- 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>
5.打包即可
方式二
配置Allatori-8.2-Demo\tutorial\step01\files\config.xml。双击RunAllatori.bat。