Maven项目源编码不起作用 [英] Maven project source encoding does not work
问题描述
我有一个使用以下属性配置的Maven项目:
I am having a Maven-Project which is configured using the following properties:
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
在我的机器上,使用这些设置可以正常运行.但是,在另一台计算机上,当我检出并尝试使用mvn install
进行编译时,编译器错误unmappable character for encoding ASCII
:
On my machine everything works fine with these settings. However, on another machine, when I check it out and try to build it using mvn install
the compiler errors unmappable character for encoding ASCII
:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project scuttle: Compilation failure: Compilation failure:
[ERROR] /export/local-1/julian-downloads/scuttle/src/main/java/de/fu/mi/scuttle/handlers/sakai/SakaiVV.java:[99,39] error: unmappable character for encoding ASCII
[ERROR]
[ERROR] /export/local-1/julian-downloads/scuttle/src/main/java/de/fu/mi/scuttle/handlers/sakai/SakaiVV.java:[99,40] error: unmappable character for encoding ASCII
[ERROR]
[ERROR] /export/local-1/julian-downloads/scuttle/src/main/java/de/fu/mi/scuttle/domain/sakai/SakvvTermin.java:[66,30] error: unmappable character for encoding ASCII
[ERROR]
[ERROR] /export/local-1/julian-downloads/scuttle/src/main/java/de/fu/mi/scuttle/domain/sakai/SakvvTermin.java:[66,31] error: unmappable character for encoding ASCII
我已经尝试使用-Dfile.encoding=UTF-8
运行mvn
,但这没有帮助. $LC_CTYPE
报告UTF-8
.
I've already tried running mvn
with -Dfile.encoding=UTF-8
but that did not help. $LC_CTYPE
reports UTF-8
.
我该怎么办?
您可以在此处看到完整的pom文件: https://github.com /scravy/scuttle/blob/master/pom.xml
You can see the complete pom file here: https://github.com/scravy/scuttle/blob/master/pom.xml
推荐答案
最后khmarbaise的评论帮助我找到了解决方案:
In the end the comment by khmarbaise helped me find a solution:
我配置了编译器插件并在其中指定了源编码,现在一切都可以在任何地方使用
I configured the compiler plugin and specified the source encoding there, now everything works everywhere:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
这篇关于Maven项目源编码不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!