Maven dependency to jar in Nexus

Viacheslav Shalamov :

How can I add a dependency to a jar, which is in my private maven repository?

I have a private nexus repository, say: https://localhost/repository/my-team/

In one project, I generate, compile and pack to a jar some java classes. say, my.jar. Then I upload it to nexus as a jar:

curl --upload-file my.jar \ 
     "https://localhost/repository/my-team/com/example/artifact/my.jar"

In another project I want to refer to this jar as a dependency:

<repositories>
     <repository>
        <id>nexus</id>
        <url>https://localhost/repository/my-team/</url>
    </repository>
</repositories>

How can I add a dependency in this case? Where do I specify the url to that jar file?

JF Meier :

In Maven, you don't handle jars by urls, but by GAVs (GroupId, ArtifactId, Version).

You don't upload it with curl, but you use mvn deploy (for building and deploying a jar) or mvn deploy:deploy-file if you have a jar already and want to deploy it.

It will be stored using the GAV (or coordinates) given in the pom.xml.

You then use the same GAV to reference it as dependency.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=157639&siteId=1