当前位置: 首页 > 工具软件 > Allatori > 使用案例 >

springboot项目Allatori代码混淆

葛季萌
2023-12-01

1.到官网下载混淆所需要的jar包:allatori.jar

        官网地址:http://www.allatori.com

2.pom文件中添加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>${project.basedir}/target</outputDirectory>
                <resources>
                    <resource>
                        <directory>${project.basedir}/src/main/resources</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>

            <!-- Copy allatori.jar to 'allatori' directory to use the commented line -->
            <argument>${basedir}/lib/allatori.jar</argument>
            <!-- <argument>${basedir}/allatori/allatori.jar</argument> -->
            <argument>${basedir}/src/main/resources/allatori.xml</argument>
        </arguments>
    </configuration>
</plugin>
<!-- Allatori plugin end -->

3./src/main/resources目录下添加混淆配置文件allatori.xml,内容如下:

<config>
    <input>
        <jar in="${project.build.finalName}.jar" out="${project.build.finalName}-obfuscated.jar"/>
    </input>

    <keep-names>
        <class access="protected+">
            <field access="protected+"/>
            <method access="protected+"/>
        </class>
    </keep-names>

    <property name="log-file" value="log.xml"/>
</config>

4.编译打包

 类似资料: