maven“找不到符号"消息无益 [英] maven "cannot find symbol" message unhelpful

查看:38
本文介绍了maven“找不到符号"消息无益的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常简单的问题,它可能是我不知道的某个设置,但 Google 对这个问题特别没有帮助,提供有关编译错误的结果,而不是如何更改编译错误消息.

This is a really simple question, and it's probably a setting somewhere I don't know about, but Google is being particularly unhelpful for this question, giving results about compilation errors, not how to change compilation error messages.

当我使用 maven 构建我的项目时,它会给出格式大致如下的错误消息:

When I build my project with maven, it will give me error messages formatted roughly as follows:

[ERROR]/path/to/source/Main.java:[13,8] 错误:找不到符号

[ERROR] /path/to/source/Main.java:[13,8] error: cannot find symbol

当我用 ant 或 javac 构建时,它实际上会告诉我它在错误消息中找不到的符号.maven 给了我一个行号和字符位置,但显示实际符号会更有帮助.上面的行是针对每个找不到符号"错误给出的唯一行.上面或下面没有给出符号的线.我想必须有某种方式让 maven 告诉我这些信息,但我不知道它是什么.我尝试了 -e 选项,因为 mvn 告诉我尝试使用它,但它给出了错误的 maven 回溯,而不是实际的符号.

When I build with ant or javac, it will actually tell me the symbol that it can't find in the error message. maven gives me a line number and character position, but displaying the actual symbol would be more helpful. The line above is the only line given for each of the "cannot find symbol" errors. There is no line above or below that gives the symbol. I imagine there has to be some way to get maven to tell me that information, but I don't know what it is. I tried the -e option, as mvn told me to try using it, but it gave a maven traceback for the error, not the actual symbol.

有什么帮助吗?

这是 mvn --version 的输出

Here's the output of mvn --version

Apache Maven 3.0.4 (rNON-CANONICAL_2012-10-24_11-25_mockbuild; 2012-10-24 07:25:04-0400)
Maven home: /usr/share/maven
Java version: 1.7.0_09-icedtea, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.6.6-1.fc17.x86_64", arch: "amd64", family: "unix"

这是一个示例(无用的)错误消息,与 maven 的输出完全相同(只是目录缩短了):

And here's an example (unhelpful) error message, exactly as output by maven (just with directories shortened):

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /path/to/source/SoundEngineFilePanel.java:[33,8] error: cannot find symbol
[ERROR]  class SoundEngineFilePanel
/path/to/source/SoundEngineFilePanel.java:[36,8] error: cannot find symbol
[INFO] 2 errors 
[INFO] -------------------------------------------------------------

它找不到的符号是fakeThing"和fakeThing2",而不是 SoundEngineFilePanel.

The symbols it can't find are "fakeThing" and "fakeThing2", not SoundEngineFilePanel.

推荐答案

这是一个 错误 在 Maven 编译器插件中,我认为与 JDK7 相关.与 JDK6 配合良好.

This is a bug in the Maven compiler plugin, related to JDK7 I think. Works fine with JDK6.

这篇关于maven“找不到符号"消息无益的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆