Reputation: 549
I'm using eclipse Luna, maven 3.0.5 and Java 6. I'm working on 2 projects in eclipse.
Project A
package com.project.one;
public class Test{
public String name="David";
}
Project B
package com.project.two;
import com.project.one.Test;
public class Hello{
public static void main(String[] args){
Test test = new Test();
System.out.println("Hello "+test.name);
}
}
I add project A to project B using Build Path (Right click on project B's folder in eclipse --> properties --> build path --> projects --> add)
, it's success but when the project B i compile using mvn clean package
i got an error, and it said
BUILD FAILURE
[ERROR] D:\xxx\Hello.java:[2,20] package package com.project.one does not exist
also line 5 and 6 is error (cannot find symbol)
So anyone can help me to resolve it?
Upvotes: 1
Views: 3117
Reputation: 2943
You need to set maven dependencies explicilty. SO in projectB pom,xml you should explicilty mention your compile/run time dependency on project a
<dependency>
<groupId>com.project</groupId>
<artifactId>projectA</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
Upvotes: 1