Maven 编译拷贝资源的时候提示 UTF-8 编码信息

时间:2022-07-26
本文章向大家介绍Maven 编译拷贝资源的时候提示 UTF-8 编码信息,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

如下面的提示内容。

提示的是在拷贝资源文件的时候,因为没有指定编码,将会使用 UTF-8 对编码进行转换。

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 2 resources
[INFO] Copying 2 resources
[INFO] The encoding used to copy filtered properties files have not been set. This means that the same encoding will be used to copy filtered properties files as when copying other filtered resources. This might not be what you want! Run your build with --debug to see which files might be affected. Read more at https://maven.apache.org/plugins/maven-resources-plugin/examples/filtering-properties-files.html

解决办法

在你的 pom 配置文件中 maven-resources-plugin 插件配置中,添加一个

<propertiesEncoding>UTF-8</propertiesEncoding>

这个参数。如果你的 pom 配置文件没有配置过 maven-resources-plugin 插件的话,你需要将这个插件先添加进去。

具体的配置参数如下:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <propertiesEncoding>UTF-8</propertiesEncoding>
                </configuration>
            </plugin>

上图显示了需要的配置状态。

https://www.ossez.com/t/maven-utf-8/560