Maven project with multiple modules that each have same package names and same class names but differences to said files causing "Type Already Defined" and "Method doesn't exist" issues within Eclipse.
I properly imported a Maven project (with the Maven Plugin installed) that has multiple modules "projects" into a working set. The problem is the projects have same named packages and class files but differences to the class files. Whichever project comes first in the build path of the working set is the one that eclipse looks at first for the package names and class file. For ex:
`My_Working_Set
- Login_Page
- Homepage
- Product_Page
Project Login_Page package foo.bar class User.java
public class User
{
private String name;
public User(String name)
{
this.name= name;
}
}
Project HomePage package foo.bar class User.java
public class User //Error type already defined
{
private String name;
protected int age;
private int height;
private int weight;
public User(String name, int age, int height, int weight)
{
this.name= name;
this.age = age;
this.height = height;
this.weight = weight;
}
}
Project HomePage package foo.bar2 class TempUser.java
import foo.bar.User;
class TempUser
{
private User tempUser;
public TempUser(String name, int age, int height, int weight)
{
tempUser = new User("John", 18, 69, 135); //Error create new constructor or change to User(String name)
}
}
Crude example but hope this helps.
IMPORTANT: Intellij does not have this problem but Eclipse does. How do I fix Eclipse?