使用allatori混淆spring cloud代码
上一篇使用progurad混淆spring cloud代码,实际看下来发现混淆代码效果不好,价值不大。于是改换为:allatori,在参考网上代码后,终于实验成功,过程如下:
在代码的根目录下新建文件夹lib,下载allatori,地址,下载完成后,将allatori拷贝到lib文件夹(目前已经到8.0版了)
然后在文件夹中建立配置文件,allatori.xml:
in="api-1.0-SNAPSHOT.jar" out="api-encrypted.jar"/> <class access="protected+"> "protected+"/> "protected+"/> class> <class template="class *Controller"> "private+ *(**)" parameters="keep"/> class> "log-file" value="log.xml"/> <class template="class *springframework*" /> <class template="class *shardingjdbc*" /> <class template="class *jni*" /> <class template="class *alibaba*"/> <class template="class *persistence*"/> <class template="class cn.*******.App"/> <class template="class cn.*******.entity.*" /> <class template="class cn.*******.mapper.*" /> <class template="class cn.*******.web.*" />
然后,在pom文件中引入2个插件:
<plugin> <groupId>org.apache.maven.pluginsgroupId> <artifactId>maven-resources-pluginartifactId> <version>2.6version> <executions> <execution> <id>copy-and-filter-allatori-configid> <phase>packagephase> <goals> <goal>copy-resourcesgoal> goals> <configuration> <outputDirectory>${basedir}/targetoutputDirectory> <resources> <resource> <directory>${basedir}/libdirectory> <includes> <include>allatori.xmlinclude> includes> <filtering>truefiltering> resource> resources> configuration> execution> executions> plugin> <plugin> <groupId>org.codehaus.mojogroupId> <artifactId>exec-maven-pluginartifactId> <version>1.2.1version> <executions> <execution> <id>run-allatoriid> <phase>packagephase> <goals> <goal>execgoal> goals> execution> executions> <configuration> <executable>javaexecutable> <arguments> <argument>-Xms128margument> <argument>-Xmx512margument> <argument>-jarargument> <argument>${basedir}/lib/allatori.jarargument> <argument>${basedir}/target/allatori.xmlargument> arguments> configuration> plugin>
另外,最好携带上maven打包插件,这样打包时会携带上所需要的jar
<plugin> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-maven-pluginartifactId> plugin>
然后打包,打包后再点击package,则会将打包后的jar加密成可执行的加密包。
参考:allatori代码混淆实现(springboot、springmvc)