简体   繁体   中英

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, ie adding the maven dependencies of all the projects added to the Classpath tab to the classpath? How can I do that?

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.

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

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