Deploy third-party maven project private dependencies to maven private server


Previously, I had been using the method of manually uploading jars and throwing third-party dependencies directly into the maven private server. This time I got the source code of the project and thought about deploying it directly in IDEA.

As a result, the configuration took a long time, and there were various problems; here is a record of the pitfalls.

问题1:[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project XXX: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRep

At the beginning, I directly used IDEA's maven deploy, and then the error message was as above. Then I looked at the pom file and found that there was no configuration in it distributionManagement, so I added it. Add the following content directly at the bottom of the pom file:

    <distributionManagement>
        <repository>
            <id>nexus</id>
            <name>maven-public</name>
            <url>http://192.168.124.241:8081/repository/maven-releases/</url>
            <uniqueVersion>true</uniqueVersion>
        </repository>
        <snapshotRepository>
            <id>nexus</id>
            <name>snapshots</name>
            <url>http://192.168.124.241:8081/repository/maven-releases/</url>
        </snapshotRepository>
    </distributionManagement>

Question 2: 401 Unauthorized

repositoryThere are two points to note here. The first is that the above needs to be consistent idwith the local maven file, because the account and password of the maven private server configured inside are used, which is in:setting.xmlsetting.xml

<server>
	<id>nexus</id>
	<!-- 用户名和密码 -->
	<username>admin</username>
	<password>admin123456</password>
</server>

Otherwise it will prompt:401 Unauthorized

Question 3: 405 PUT

At the beginning, the address configured above was: repositoryand then an error 405 was reported; after checking the information, it was found that this address needs to use the hosted type nexus warehouse in the maven private server; then it was changed to .urlhttp://192.168.124.241:8081/repository/maven-public/

Insert image description here
/repository/maven-releases/

Guess you like

Origin blog.csdn.net/linmengmeng_1314/article/details/128921236