0
votes

I have used this command to push my jar to maven repository.(created jar using mvn clean install)

mvn install:install-file -Dfile=abc-model-1.0-SNAPSHOT.jar -DgroupId=com.abc -DartifactId=abc-model -Dversion=1.0-SNAPSHOT -Dpackaging=jar -DgeneratePom=true

After successfully adding the jar to local mvn repository I have added the following as the dependency where I am going to use it.

 <dependency>
       <groupId>com.abc</groupId>
       <artifactId>abc-model</artifactId>
       <version>1.0-SNAPSHOT</version>
 </dependency>

But I am unable to access packages inside the jar. And also it is not in the External Libraries also. I have some model classes that I am trying to do is use those in a different project.

1
Please show us the error you get when you build, e.g. with mvn clean verify. - J Fabian Meier
There is no error with that. My dependency is not loaded to External Libraries. - K Rajitha
If you can build with mvn clean install without error, then all necessary libraries are there. It might be that Eclipse or IntelliJ don't show them, but that is another story. - J Fabian Meier

1 Answers

-1
votes

Finally, I have figure out the problem. This can be affected by 2 ways.

  1. I have used the IntelliJ terminal to build the project. But it didn't work. But when I use the CMD(terminal) it worked as expected.

and also

Previously I have used that dependency as follows. in Scope Compile is the default. But after I adding the scope only it worked as expected. I cannot say the exact reason for this.

    <dependency>
        <groupId>com.abc.models</groupId>
        <artifactId>abc-model</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

Forgot to give the scope. After adding Scope like this it worked.

    <dependency>
        <groupId>com.abc.models</groupId>
        <artifactId>abc-model</artifactId>
        <version>1.0-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>