The
To use the jar in the client project I have added this as a dependency in the client project.
<dependency>
<groupId>com.sagar</groupId>
<artifactId>libraray001</artifactId>
<version>0.0.3-SNAPSHOT</version>
<classifier>exec</classifier>
</dependency>
This gets the project into the external libraries part of the client project. and this has the class that I want to use in the library (TestModel001).
But when I try to import this into any classes that I want to use it can not resolve the import.
How do I use the library project in this project?
CodePudding user response:
The client project as visible at sagarnayak/repoclientproject is not configured to consume the artifacts from the private Maven repository hosted on GitHub as described in the Working with the Apache Maven registry.
Specifically, following settings are missing:
<repositories>
configuration in pom.xml
<servers>
configuration in local settings.xml
Add following elements to the pom.xml
:
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/sagarnayak/</url>
</repository>
</repositories>
Add following elements to the settings.xml
<servers>
<server>
<id>github</id>
<username>sagarnayak</username>
<password>YOUR_PERSONAL_ACCESS_TOKEN_HERE</password>
</server>
</servers>
Note: Keep settings.xml
local to your machine - don't leak that Personal Access Token!
CodePudding user response:
You are packaging the library via spring-boot-maven-plugin
It produces a JAR that has a self-running spring boot structure, and so you are unable to import it as a library correctly.
Try to remove spring-boot-maven-plugin
from your libraray001
pom.xml, rebuild, republish and try to consume that artifact in your client
project again, refreshing the dependencies and preferably bumping up the library version, to exclude caching possibility during the test.