简体   繁体   English

Maven和Eclipse有很多“疯狂”错误

[英]Got a lot of 'crazy' errors with Maven and Eclipse

I was able to make my project work with Maven, GWT (with mojo plugin), GWTP, Hibernate and everything else, however, it appears that Eclipse goings crazy. 我能够使我的项目与Maven,GWT(带有mojo插件),GWTP,Hibernate和其他所有功能一起使用,但是,Eclipse似乎发疯了。

Randomly, sometimes it simply stop to recognize the classes, I try to run a class called "Test", for example, and he accuses error in the console, saying that this class was not found. 随机地,有时它只是停止识别这些类,例如,我尝试运行一个名为“ Test”的类,他在控制台中指责错误,称未找到该类。

Also, happens sometimes the classes are outdated, for some reason. 此外,有时由于某些原因有时会过时。

Has anyone faced this kind of problem? 有人遇到过这种问题吗?

Thanks in advance. 提前致谢。

[EDIT] look like it happens when I do a mvn clean install, and after a lot of refreshes, close and reopen eclipse, clean project and all that stuff, it works again.. [编辑]看起来像是当我执行mvn全新安装时发生的,经过大量刷新后,关闭并重新打开eclipse,清除项目以及所有类似的东西,它再次起作用。

[EDIT2] The problem occurs when I use mvn command externally and the Maven plugin for eclipse, the "target" directory becomes full of trash, and everything goings crazy. [EDIT2]当我在外部使用mvn命令并将Maven插件用于eclipse时,会出现问题,“目标”目录充满了垃圾,一切都变得疯狂。

So, the solution is the answer from @icfantv. 因此,解决方案是@icfantv的答案。 I do what he said and everything works. 我照他说的做,一切正常。

Another tip is to put attention in Java compile version that eclipse use... sometimes the maven set the project settings to use java 1.5 standart, and things like annotations stop working. 另一个技巧是在eclipse使用的Java编译版本中引起注意...有时maven将项目设置设置为使用Java 1.5标准,并且注释之类的东西将停止工作。

Hope this edit make question better explained. 希望此编辑可以使问题得到更好的解释。

It sounds like your problem has to do with using Maven to clean files shared by Eclipse. 听起来您的问题与使用Maven清除Eclipse共享的文件有关。 If you do a mvn clean from the command line, and it removes the class files that Eclipse is depending on, it will cause an error when it's time to run them in Eclipse. 如果从命令行执行mvn clean ,并且它删除了Eclipse依赖的类文件,那么当需要在Eclipse中运行它们时,将导致错误。

You will have to refresh and rebuild the project in Eclipse if you are modifying things outside of it. 如果要在Eclipse中进行外部修改,则必须在Eclipse中刷新和重建项目。

If you do everything (including builds) via Eclipse, then this doesn't apply, but if you also use the command line then it sounds like you may be sharing your build directories which can cause all sorts of issues in Eclipse. 如果您通过Eclipse完成所有工作(包括构建),那么这并不适用,但是如果您还使用命令行,那么听起来您可能正在共享构建目录,这可能会在Eclipse中引起各种问题。

Try setting a different target directory for your build so as to not interfere with Maven's default directories: Project > Properties > Java Build Path. 尝试为构建设置另一个目标目录,以免干扰Maven的默认目录:“项目”>“属性”>“ Java Build Path”。 Click on the Source tab if it is not selected. 如果未选中,请单击“源”选项卡。 The textfield at the bottom is where you can change it within Eclipse. 您可以在底部的文本字段中在Eclipse中进行更改。

Basically, you shouldn't be sharing your build files between a command line build and the IDE. 基本上,您不应该在命令行构建和IDE之间共享构建文件。

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

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