In Maven engineering, resource files are typically placed under the/src/test/resources path, and resource file descriptions are configured in Pom.xml:
<resources>
<resource>
<directory>src/main/resources</directory>
< filtering>true</filtering>
</resource>
</resources>
This specifies that the files under the path are automatically copied to the classes directory when they are packaged.
However, this configuration uses the
<filtering>true</filtering>
Indicates that the file under this path needs to filter the ER expression in the Copy project and replace the expression with the configured value.
However, the problem appears in this step, the replacement process does not specify the encoding of the file, resulting in the replacement of the file may have garbled problems.
The solution is as follows:
To add a configuration to the Pom.xml file
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</ version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
This means that the file encoding used to filter files is specified by the plugin, avoiding the garbled behavior.
Of course, direct use
<filtering>false</filtering>
There is no such problem.