I usually work on both terminal and Eclipse for my development.
Like compiling, creating of the war using maven and usage of Tomcat from terminal, and for coding Eclipse.
But, there are times I might need Eclipse like for debugging. And I want to run Tomcat from Eclipse itself.
I was using Helios, the project runs great from terminal. But, when I try it from Eclipse, it is not publishing it b/c it can’t get the jars.
I have updated the maven dependency and everything seems there. Like when I am developing, Eclipse knows about the imported files and I had no problem.
In short, eclipse can’t import the jars from maven or eclipse class path error was there while reading from maven.
Solution to how to import dependencies from maven to eclipse or how to import jars from maven to eclipse
1. Make sure you have the M2E plugin on your eclipse. To check that:
1.a Go to Eclipse–Help–Install new software
1.b On the work with text box insert Sonatype – http://m2eclipse.sonatype.org/sites/m2e and follow the wizard
When you are done restart your eclipse
2. Check if M2_REPO class path variable is there. To check that:
2.a Window–Preferences–Java–Build Path–Classpath Variable in this there should be M2_REPO variable being set. If it is not set, click the New button and add the repository of your maven path there.
3. Go to Window–preference–Maven–User Settings and check if there are not any warnings there. Mostly on User Settings. If there is one, update with the correct one. I am on Ubuntu and mine is on /etc/maven2/settings.xml
Go to your terminal and issue mvn eclipse:eclipse
then, right click on your project–maven and hit update dependencies.
Here is the fun part::
right click on your project, select build path and look at the library tab your dependencies would be listed there with M2_REPO path at the beginning
Then, Click on Deployment Assesment, it is right above Java Build Path, Select Java Build Path Entries
Hit next, select all the listed ones and hit finish
Refresh the project, clear the tomcat and all should be fine.
This should fix your eclipse class not found exception only because it not reading from maven correctly problem