赞
踩
具体如下:
<build> <plugins> <!-- 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>
在项目的resources目录下创建一个allatori.xml文件,具体名称可自行修改,和pom配置保持一致即可。具体内容如下:
<!--allatori配置文件--> <config> <!-- 输入和输出jar配置,out指向的是加密后的jar --> <input> <jar in="xx-api-service-0.0.1-SNAPSHOT.jar" out="obf-xx-api-service-0.0.1-SNAPSHOT.jar"/> </input> <!-- 加水印 --> <watermark key="secure-key-to-extract-watermark" value="developer: xxx"/> <!-- 需要保留原来类名的配置 --> <keep-names> <class access="protected+"> <field access="protected+"/> <method access="protected+"/> </class> <class template="class com.xxx.xxx.*"/> </keep-names> <property name="log-file" value="log.xml"/> <ignore-classes> <class template="class *springframework*"/> <class template="class *shardingjdbc*"/> <class template="class *jni*"/> <class template="class *alibaba*"/> <class template="class *persistence*"/> <class template="class *apache*"/> <class template="class *mybatis*"/> <!-- 排除包下的类,可单个到具体,注意此处一定要排除掉springboot项目的启动类 --> <class template="class com.apache.*"/> <class template="class org.apache.http.entity.StringEntity"/> <class template="class org.apache.cxf.*"/> </ignore-classes> </config>
好了,到此结束。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。