Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Run Configurations: how to add Maven dependencies of projects added to Classpath

I'm using Eclipse version Oxygen.2 Release (4.7.2) with M2E version 1.8.2.20171007-0217 on Windows 7.

When I define a new RUN configuration I can see the Maven dependencies of the Main project (the one defined in the Main tab of the "Run Configurations" dialog) in the Classpath tab.

However, I cannot add the Maven dependencies of the other projects that I added to the Classpath tab, under "User Entries". The result is that I get ClassNotFoundException. To solve that, I need to explicitly add the external JARs from my local .m2 repository.

I googled around to see if I could find a solution but I could not find anything useful.

Is it possible to do what I am trying to do, i.e. adding the maven dependencies of all the projects added to the Classpath tab to the classpath? How can I do that?

like image 444
Claves DOA Avatar asked Jan 22 '18 09:01

Claves DOA


2 Answers

No not possible. Or if it is possible - it is not correct to do so. If you use maven, you need to add those dependencies to the pom.xml of you project.

like image 129
ACV Avatar answered Sep 22 '22 19:09

ACV


Ok, here is a solution I found and it worked for me.

First, I removed each project from the others build path, this way, they don't see each other.

Then in eclipse, I converted the projects to maven, and got the pom.xml file(s)

Then, I installed the projects with: mvn install. This way, I got the projects into my local repository and could add them as dependencies to my other projects pom file

like image 33
Elydasian Avatar answered Sep 24 '22 19:09

Elydasian