如何在Maven中配置编码? [英] How to configure encoding in Maven?
问题描述
当我在我的多模块 maven 项目上运行 maven install
时,我总是得到以下输出:
[WARNING] 文件编码尚未设置,使用平台编码 UTF-8,即构建依赖于平台!
所以,我用谷歌搜索了一下,但我只能找到我必须添加的内容:
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></属性>
...到我的 pom.xml.但它已经存在(在父 pom.xml
中).
为 maven-resources-plugin 或 maven-compiler-plugin 配置
也不能修复它.
有什么问题吗?
好的,我已经找到问题了.
我使用了一些报告插件.在 failsafe-maven-plugin 的文档中
我发现
配置 - 当然 - 默认使用 ${project.reporting.outputEncoding}
.>
所以我将该属性添加为 project
元素的子元素,现在一切正常:
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding></属性>
另见 http://maven.apache.org/general.html#encoding-警告
When I run maven install
on my multi module maven project I always get the following output:
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
So, I googled around a bit, but all I can find is that I have to add:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
...to my pom.xml. But it's already there (in the parent pom.xml
).
Configuring <encoding>
for the maven-resources-plugin or the maven-compiler-plugin also doesn't fix it.
So what's the problem?
OK, I have found the problem.
I use some reporting plugins. In the documentation of the failsafe-maven-plugin
I found, that the <encoding>
configuration - of course - uses ${project.reporting.outputEncoding}
by default.
So I added the property as a child element of the project
element and everything is fine now:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
See also http://maven.apache.org/general.html#encoding-warning
这篇关于如何在Maven中配置编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!