spring boot混淆jar包

使用破解的allatori包,最后面有链接

pom 文件(项目中完整的一个pom打包代码,可以替换掉对应的路径信息)

<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>-Xmx5120m</argument>
						<argument>-jar</argument>
						<argument>${basedir}\src\main\resources\lib\allatori.jar</argument>
						<argument>${basedir}/allatori.xml</argument>
					</arguments>
				</configuration>
			</plugin>
			<!-- Allatori plugin end -->
			
		
		<!-- 代码混淆↑ -->
		


			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<mainClass>com.ireal.crpas.CrpasCfgsrvApplication</mainClass>
					<includeSystemScope>true</includeSystemScope>
					<!-- <classifier>exec</classifier> -->
				</configuration>
				<!--测试热更新  -->
				<dependencies>
					<dependency>
						<groupId>org.springframework</groupId>
						<artifactId>springloaded</artifactId>
						<version>1.2.6.RELEASE</version>
					</dependency>
				</dependencies>
				<!--测试热更新  -->

				<!--打包jar  -->
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
						</goals>
						<!--可以生成不含依赖包的不可执行Jar包-->
						<!-- <configuration>
                          <classifier>exec</classifier>
                        </configuration> -->
					</execution>
				</executions>
				<!--打包jar  -->
			</plugin>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>UTF-8</encoding>
					<!--配置本地jar包在项目的存放路径-->
					<!-- <compilerArguments>
                        <extdirs>${project.basedir}/src/main/resources/lib</extdirs>
                    </compilerArguments> -->
				</configuration>
			</plugin>

		</plugins>


		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<includes>
					<include>**/*.properties</include>
					<include>**/*.xml</include>
					<include>**/*.tld</include>
				</includes>
				<filtering>false</filtering>
			</resource>
			<resource>
				<directory>src/main/java</directory>
				<includes>
					<include>**/*.properties</include>
					<include>**/*.xml</include>
					<include>**/*.tld</include>
				</includes>
				<filtering>false</filtering>
			</resource>
			<resource>
				<directory>${project.basedir}/src/main/resources/lib</directory>
				<targetPath>BOOT-INF/lib/</targetPath>
				<filtering>false</filtering>
				<includes>
					<include>*.jar</include>
				</includes>
			</resource>
		</resources>

	</build>

allatori.xml 配置

in 为原始jar包,out为混淆后的jar位置名称(自定义)

<jar in="*.jar" out="*.jar"/>
<config>
    <input>
        <jar in="target\crpas-cfgsrv-0.0.1-SNAPSHOT.jar" out="target\crpas-cfgsrv-0.0.1-SNAPSHOT-obfuscated.jar"/>
        <!-- <jar in="target\crpas-0.0.1-SNAPSHOT.war" out="target\crpas-0.0.1-SNAPSHOT-obfuscated.war"/> -->
    </input>

 	<classpath basedir="library-jars">
        <!-- 将library.jar添加到类路径 -->
        <jar name="snmp4j-2.5.11.jar"/>
        <jar name="*.jar"/>
        <!-- 将lib目录中的所有jar添加到类路径 -->
        <!-- <jar name="lib/*.jar"/> -->
        <!-- 将lib2目录及其子目录中的所有jar添加到类路径 -->
        <!-- <jar name="lib2/**/*.jar"/> -->
    </classpath>
    
    <keep-names>
        <class access="protected+">
            <field access="protected+"/>
            <method access="protected+"/>
        </class>
        
         <!-- Matches serialization members -->
        <class template="class * instanceof java.io.Serializable">
            <!-- <field template="static final long serialVersionUID"/>
            <method template="void writeObject(java.io.ObjectOutputStream)"/>
            <method template="void readObject(java.io.ObjectInputStream)"/>
            <method template="java.lang.Object writeReplace()"/>
            <method template="java.lang.Object readResolve()"/> -->
        </class>
        
         <!-- Matches classes with the name ending with "Bean" -->
        <class template="class *">
            <!-- Matches all static fields -->
            <field template="static *"/>
            <!-- 不混淆所有public的变量 -->
            <field template="public *"/>
            <!-- Matches protected and public String fields -->
            <field template="protected+ java.lang.String *"/>
            <!-- Matches all methods -->
            <method template="private+ *(**)"/>
            <!-- Matches all getter methods -->
            <method template="private+ get*(**)"/>
            <!-- Matches all methods with String argument,
                 parameter names of these methods will not be changed -->
            <method template="private+ *(java.lang.String)" parameters="keep"/>
        </class>
        
    </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*"/> 
	<class template="class *javax*"/>  	
	<class template="class *io*"/>  
	<!-- 排除如下两个包下的类 -->
	<class template="class *Msg*" />
	<class template="class com.ireal.crpas.apps.dao.*" />
	<class template="class com.ireal.crpas.apps.model.*" />
	<class template="class com.ireal.crpas.apps.mapper.*" />
	<class template="class com.ireal.crpas.apps.service.*" />
	<class template="class com.ireal.crpas.apps.controller.*" />
	<class template="class org.apache.http.entity.StringEntity"/>  
	
	<class template="class com.ireal.crpas.protocol*"/>  
	<class template="class * instanceof java.io.Serializable"/>
	<!-- <class template="class com.ireal.crpas.test.SerachSnmp.socket.*"/> -->
</ignore-classes>

</config>

打包时可能会有一些包找不到,可以建一个文件夹引入进来,我自己的配置是

library-jars文件夹

各文件的位置

配置完后使用maven clean package打包即可,打包完后target目录下会有两个jar,一个是maven打包的jar,一个是混淆后的jar

需要的jar,在分享的资源里面,一共两个包

https://download.csdn.net/download/qq_38653209/14892478?spm=1001.2014.3001.5501https://download.csdn.net/download/qq_38653209/14892478?spm=1001.2014.3001.5501

allatori.jar_allatori免费吗-Java文档类资源-CSDN下载allatori混淆用到的jarallatori免费吗更多下载资源、学习资料请访问CSDN下载频道.https://download.csdn.net/download/qq_38653209/14892461?spm=1001.2014.3001.5501


版权声明:本文为qq_38653209原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。