10

In an eclipse project, I referenced a class that was currently not in project's build path.

In the context sensitive pop-up that opens by hovering the mouse over the error, "Fix project setup" option has offered me to add a jar to the build path of the project. This jar is in my local maven repository.

However, the "correct" way to fix it is obviously by adding the relevant dependencies to my project's pom, instead of adding this jar to the build path of the project.

So is there a way to configure eclipse, so that it won't offer to add a maven repo jar to the build path, but it will offer to fix the project's pom?

Utku
  • 2,025
  • 22
  • 42

2 Answers2

6

This feature used to exist in m2eclipse (the predecessor of m2e), see e.g. https://blog.sonatype.com/2010/03/adding-dependencies-using-m2eclipse/ which shows a "Search dependency for XXX" quickfix above the "Fix project setup..." quickfix.

Unfortunately it didn't make it into m2e, see https://www.eclipse.org/lists/m2e-users/msg01130.html

Till Brychcy
  • 2,876
  • 1
  • 18
  • 28
-1

Make sure:

  1. your project is fine outside of eclipse using only maven/pom, mvn clean install (or similar) in an external shell/console

  2. your eclipse project has maven nature

  3. Eclipse -> Project -> Build Automatically is checked

  4. Refresh your eclipse project

  5. Do something in the pom.xml (save file) should trigger a build

Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85
  • 1
    IMHO, the question is about a feature of Eclipse that automatically connects (missing) classes with Maven artifacts. This could be a useful feature, if you could automatically add the derived artifact to the POM instead of the Eclipse classpath. – J Fabian Meier Sep 24 '18 at 11:24