foreword
Earlier we talked about how to obfuscate code at . The article mentioned that there is a small pit in the use of allatori in the springboot project. This pit is when you configure in allatori.xml
<input>
<jar in="${project.build.finalName}.jar" out="${project.build.finalName}.jar"/>
</input>
${project.build.finalName} will be output as a string without parsing placeholders. As a result, the following error will be reported in the package
Reason for failure
This is the original words of the official website, to the effect that if you use spring-boot-starter-parent, maven-resources-plugin only recognizes @
Why only recognize @, I posted the configuration of spring-boot-starter-parent pom, probably everyone knows what happened
Repair plan
Option 1: According to the official website, change ${project.build.finalName} to @project.build.finalName@
<input>
<jar in="@project.build.finalName@.jar" out="@project.build.finalName@.jar"/>
</input>
Option 2: Instead of directly introducing spring-boot-starter-parent, use
dependencyManagement, the placeholder is still ${project.build.finalName}
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Option 3: Modify the configuration of maven-resources-plugin
set useDefaultDelimiters to true
Example:
Option 4: In the properties tag of pom, configure the following properties
<properties>
<resource.delimiter>${}</resource.delimiter>
</properties>
Summarize
The essential reason why springboot makes maven-resources-plugin placeholder invalid is that springboot modifies the default placeholder of maven-resources-plugin. Why does springboot do this, his official website said the reason
The gist of it is to prevent any Spring placeholders in the configuration (eg ${foo}) from being built to extend. Therefore, it is recommended to use @
demo link
https://github.com/lyb-geek/springboot-learning/tree/master/springboot-proguard
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。