开发者

Eclipse IDE behaves weirdly

开发者 https://www.devze.com 2023-03-06 07:28 出处:网络
I am getting a class not found exceptio开发者_JS百科n for my Login Controller when I try to login to my application(It is a spring MVC Application). Before running the maven clean command the Applicat

I am getting a class not found exceptio开发者_JS百科n for my Login Controller when I try to login to my application(It is a spring MVC Application). Before running the maven clean command the Application was running perfectly, I used maven clean and then again done a build using maven package command, suddenly it stopped working. I tried restarting the TomCat, re-deployed the application on TomCat, restarted the Eclipse IDE but nothing has worked so far.

Why this happens and what is the possible solution to this ??


Are you trying to run your project under Eclipse? And does it generate source files? If these are both true, you probably need to update the project config (select project or pom, right-click, Maven..Update..Project Configuration and Maven..Update..Project Dependencies).

The problem is that when Maven does a clean, it gets rid of the generated directories, which Eclipse observes and removes from your Build Path. But then when Maven rebuilds the directories, Eclipse doesn't notice it - you have to give it a hint.


Check your project for build errors and build path errors. Make sure you've defined an M2_REPO classpath variable in Eclipse (Preferences - Java - Build Path - Classpath Variables).

If you're using the m2eclipe plugin, right-click your project and click on Maven - Update project configuration. That will configure an Eclipse build path for your project based on your pom dependencies.

If you're not using m2eclipse, execute mvn eclipse:clean eclipse:eclipse in your project folder. Then refresh your project in Eclipse.


What you haven't said is that you've checked and the missing class is in fact present. A quick way to check is in the code editor SHIFT+CTRL+T and type the name of the missing class. Eclipse should not only show you the class if it exists, on highlighting the class, Eclipse should tell you which jar it is in.

Based on the info you have provided, I would say some dependecy in your POM has been removed by mistake or you need a newer version of some jar. If you find the class is not present, then you can figure out which jar you need by googling something like Maven 2 MyMissingClass jar that usually works for me.


Delete the .metadata folder in your eclipse workspace and then again open the workspace and import the required project.

This will solve your problem.

In .metadata folder it maintains the temporary copy of the project.


what worked in my case was simply removing the project from work space and importing it back again.

But I still don't know why it worked Vs why other things mentioned did not work (I tried updating dependencies in fact I removed all the dependencies from pom.xml and added everything again)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号