首页 > 技术文章 > IDEA配置连接(自建Maven仓库)私服并打包上传、私有仓库,本地jar包上传到私有仓库

pxblog 2021-06-28 10:07 原文

 

 

maven的setting.xml文件配置

在servers标签里配置

 

 <server>
        
        <id>privete_maven</id>
        <!--账号密码需要与私服登录账号密码一致-->
        <username>admin</username>
        <password>123456</password>
    </server>

 

 

在项目的pom.xml文件增加 这里的ID要和上面的ID对应

 

 

 <distributionManagement>
        <repository>
            <id>privete_maven</id>
            <name>Nexus Release Repository</name>
            <url>http://192.168.1.2:8010/nexus/repository/maven-releases/</url>
        </repository>
    </distributionManagement>

 

 

 

 然后点击deploy

 

 

如果是本地jar包上传到私有仓库的话 ,使用

mvn deploy:deploy-file -DgroupId=org.apache.commons  -DartifactId=commons-io  -Dversion=2.2  -Dpackaging=jar  -Dfile=commons-io-2.2.jar   -DgeneratePom=true  -Durl=http://xxxxxx/list/maven-local/ -DrepositoryId=privete_maven

 

file:是本地jar包路径

url:是私有仓库地址

repositoryId:和上面maven的setting文件里的private_maven对应,那个是设置了账号密码,名称可以根据自己的来

 

然后在jar包目录

 

推荐阅读