简体   繁体   English

Maven 错误:用于编码 Cp1251 的不可映射字符

[英]Maven error: unmappable character for encoding Cp1251

Can't compile your project in NetBeans, here is the error:无法在 NetBeans 中编译您的项目,这是错误:

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 4.094s
Finished at: Sat Nov 17 00:23:08 MSK 2012
Final Memory: 8M/247M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project AdminCmd: Compilation failure
C:\Users\Максим\Documents\NetBeansProjects\AdminCmd\src\main\java\be\Balor\Tools\Help\String\ACMinecraftFontWidthCalculator.java:[30,33] error: unmappable character for encoding Cp1251
-> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

here's the file maven on that swears这是文件 Maven 发誓

http://pastebin.com/buQEE4Fb http://pastebin.com/buQEE4Fb

Project to Git - https://github.com/Belphemur/AdminCmd项目到 Git - https://github.com/Belphemur/AdminCmd

If someone could put a working draft of NetBeans or Eclipse!如果有人可以提出 NetBeans 或 Eclipse 的工作草案!

This is interesting, as your pom.xml mentions这很有趣,正如你的 pom.xml 提到的

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

.. but the error message complains about Cp1251 encoding. .. 但错误消息抱怨 Cp1251 编码。 Does the maven output mention anything else related to source encodings? Maven 输出是否提及与源编码相关的任何其他内容?

My recommendation is generally to not use any high-ASCII characters in your code, and use the \\uxxxx notation instead as needed.我的建议通常是不要在代码中使用任何高位 ASCII 字符,而是根据需要使用\\uxxxx表示法。

You can make the conversion from UTF-8 to escaped unicode at online conversion sites like http://www.endmemo.com/convert/EMUnicode.php (this particular one seems to strip leading zeroes, I don't think that's legal in Java)您可以在像http://www.endmemo.com/convert/EMUnicode.php这样的在线转换站点上进行从 UTF-8 到转义 unicode 的转换(这个特定的似乎去掉了前导零,我认为这在爪哇)

You have characters in that file which are likely not mapped in the Windows codepage (which is the reference to Cp1251).该文件中的字符可能未映射到 Windows 代码页(这是对 Cp1251 的引用)。 Try changing the project encoding to UTF-8 or similar.尝试将项目编码更改为 UTF-8 或类似编码。 Look into different encoding schemes.查看不同的编码方案。

In my case I resolved that problem by setting new environment variable:在我的情况下,我通过设置新的环境变量解决了这个问题:

JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8

In the command line executing maven, run current command before executing maven command:在执行 maven 的命令行中,在执行 maven 命令之前先运行当前命令:

SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM