How to Import new version of a class from a jar file created in another Maven project [message #1864628] |
Fri, 29 March 2024 17:25 |
|
I am using the following version of Eclipse .
Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)
Version: 2023-12 (4.30.0)
Build id: 20231201-2043
I have a Maven project, say Project A, with a java file that includes the following import statement.
import org.nhindirect.config.model.Address;
A version of the Address class is also in another java file in another Maven project, Project B. I modified the class in Project B, adding a helloWorld method to it. Then, I ran "mvn clean package" on Project B using the Maven Build... tool in Eclipse to create a jar file.
In Project A, I now want to import the Address class in the newly created jar file instead of importing the old Address class as indicated above. I have added the new jar file to the Build Path of Project B in Eclipse and I can execute the method that calls the helloWorld method within Eclipse. However, when I try to run "mvn clean package" using the Eclipse Build... tool in Project A, I get the following.
"error: cannot find symbol ... symbol: method helloWorld(String)"
I am guessing that the import statement is importing from the old version of the Address class instead of the new one from the jar file when trying to Build Project A in Eclipse. I have been told that Maven does not use the Build Path when performing a Build, which I guess is the issue here.
I have a couple of questions.
1. How do I find the path to the class containing the code that the import statement is importing (i.e. Where is the path to the source of "org.nhindirect.config.model.Address" that the import statement is pointing to)?
2. How do I get Project A to use the new class instead of the old one, when performing a build, assuming that is the issue?
I have also tried copying the jar file to the .../src/main/resources/ directory of Project A, then adding the following to the pom.xml file for Project A.
<dependency>
<groupId>com.config.model</groupId>
<artifactId>sconfig-model</artifactId>
<version>6.0.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/config-model-6.0.1.jar</systemPath>
</dependency>
I then tried to change "import org.nhindirect.config.model.Address;" to "import com.config.model", but in the IDE it says "The import com.config cannot be resolved".
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06661 seconds