0

Can anyone tell me how to import java classes with the same names and same namespace (package names) into one maven project. I already include those clases in maven project using dependecy tags in pom file. When I want to create new instance of this class i can not define from which project to take class definition. Example:

In project abc i have clas definition:

    myclass.FirstClass(){
    Pivate String a;
    // getter and setter for a
    }

In project def i have clas definition:

    myclass.FirstClass(){
    Pivate String a;
    // getter and setter for a
    }

Now I want to use both of those definitions in third project where I should assign value for a atribut from class defined in abd to class defined in def project. I know it sound crazy, but I use it to map object for designig web services.

Thanks, Miha

1

This cannot be done. Java cannot distinguish two classes with the same qualified name.

You need to rename one of the packages. If at least one of the projects abc and def is yours, this can be easily done. If not, You probably need something like the Maven shade plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.