Maven和-Dfile.encoding = UTF-8

时间:2017-07-25 08:24:25

标签: maven utf-8

我使用以下命令启动Maven构建:

mvn clean install -Dfile.encoding=UTF-8

到目前为止,一切都非常好。

我想将-Dfile.encoding=UTF-8移到我的pom.xml中,以避免在mvn命令中使用此参数。

为了做到这一点,我在pom.xml中添加了以下顶级属性:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <file.encoding>UTF-8</file.encoding>
</properties>

但是当我用:

构建应用程序时
mvn clean install

应用程序失败,出现以下异常:

java.lang.IllegalStateException: The Java Virtual Machine has not been configured to use the desired default character encoding (UTF-8).

那么为什么它与-Dfile.encoding=UTF-8合作并且不能与<file.encoding>UTF-8</file.encoding>一起使用?

0 个答案:

没有答案