简体   繁体   English

Netbeans&Maven:不同的编译行为

[英]Netbeans & Maven: different compilation behavior

I am using Netbeans and Maven projects. 我正在使用Netbeans和Maven项目。
In some case Netbeans show me compilation failures (red ballon) BUT Maven compile everything without any problem! 在某些情况下,Netbeans向我展示编译失败(红色气球)但Maven编译所有内容没有任何问题!

What can be the reason of this difference. 造成这种差异的原因是什么? I already checked that both are using the same JDK version. 我已经检查过两者都使用相同的JDK版本。

One possible reason could be that you have not added the required jar in your net beans class path. 一个可能的原因可能是您没有在net beans类路径中添加所需的jar。 But the jar is being listed in your maven pom.xml 但是jar正在你的maven pom.xml中列出

Try doing this, do an mvn install once from your command line in your project directory, and then re-open or reload the project in your netbeans IDE (I hope you are using 6.9?). 尝试这样做,从项目目录中的命令行执行一次mvn install ,然后在netbeans IDE中重新打开或重新加载项目(我希望你使用的是6.9?)。

This will install all the artifacts in your local repo. 这将在您的本地仓库中安装所有工件。

This usually happens if you have modules in your maven project and they depend on each other. 如果您的maven项目中有模块并且它们彼此依赖,则通常会发生这种情况。

some more details would be needed for more in-depth analysis. 需要更多细节才能进行更深入的分析。

In most cases a difference in compilation errors between cmdline and netbeans editor can be caused by missing source roots (read generated source roots - see the project properties Sources panel on how to setup source roots). 在大多数情况下,cmdline和netbeans编辑器之间的编译错误差异可能是由于缺少源根(读取生成的源根 - 请参阅项目属性Sources面板,了解如何设置源根)。

netbeans is embedding an old svn HEAD snapshot maven binaries so in some very rare cases there could be differences in resolving the dependency tree, but I have yet to see such case. netbeans嵌入了一个旧的svn HEAD快照maven二进制文件,所以在一些非常罕见的情况下,解析依赖树可能会有所不同,但我还没有看到这种情况。

also the netbeans compiler doesn't pick up most of the switches defined on the compiler plugin apart from target/source, encoding. 除了目标/源代码编码之外,netbeans编译器也不会选择编译器插件上定义的大多数开关。

The netbeans editor compiler is not 100% compatible with jdk compiler and there have been cases of incompatibilities so we are back to the need to see the actual errors first.. netbeans编辑器编译器与jdk编译器不是100%兼容,并且存在不兼容的情况,因此我们回到需要首先看到实际错误。

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

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