Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add dependency of other maven project to my current maven project in java eclipse?

Tags:

java

maven

I want to use maven project 2 classes in my maven project 1 so that I can use it as a parent class. Can you please tell me how to do this using eclipse and JAVA. Please write in step by step navigation as I am new in maven.

Thanks in advance

like image 938
Lavish Karankar Avatar asked Oct 19 '15 07:10

Lavish Karankar


1 Answers

I know its too late But this could help others who are searching for same problem.

suppose you have 2 projects p1 and p2 and you want to use p2 project's classes in p1 project then,

A) Right Click on your p2 maven project(If not maven project then convert it to maven) then
-->Choose Run As-->Click on Maven Install. (It will make p2 to avaliable for other projects in your local maven repository)

B) Now you can simply add p2 project as dependency in p1 project's pom.xml file like this

  <dependency>
    <groupId>com.project.p2</groupId>
    <artifactId>p2</artifactId>
    <version>1.0-SNAPSHOT</version>
    <scope>compile</scope>
  </dependency>

For more details see this

like image 191
sohal Avatar answered Sep 19 '22 23:09

sohal