简体   繁体   中英

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.

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.

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..

[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.

So, the solution is the answer from @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.

Hope this edit make question better explained.

It sounds like your problem has to do with using Maven to clean files shared by 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.

You will have to refresh and rebuild the project in Eclipse if you are modifying things outside of it.

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.

Try setting a different target directory for your build so as to not interfere with Maven's default directories: Project > Properties > 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.

Basically, you shouldn't be sharing your build files between a command line build and the IDE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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