Maven 私服 自动上传部署(附快速镜像)

来源:互联网 发布:发信息软件 编辑:程序博客网 时间:2024/06/06 23:55

一、配置Maven的 settings.xml

 nexus私服是需要登陆的(可配置免登陆),在settings.xml的配置<servers></servers>

如下:

<servers><server>   <id>nexus</id>   <username>admin</username><password>xxxxx</password>   </server><server>   <id>central</id>   <username>admin</username>   <password>xxxx</password>   </server></servers>

二、 配置项目的 pom.xml

添加如下:

  <distributionManagement>   <repository>    <id>nexus</id>    <name>Internal Releases</name>    <url>http://168.10.132.150:8081/nexus/content/repositories/thirdparty/</url>   </repository>  </distributionManagement>

三、其它问题

请确保 maven 私服开启了上传部署策略:

1.登录到maven私服,点击“Repositories”在右侧的列表中找到要使用的私服仓库,最右侧为仓库地址(复制这个地址,私服镜像和上传都要用到)

2.点击该仓库后,在下面找到“Configuration”标签页,找到“Deployment Policy”项,将其修改为:Allow Redeploy

3.点击最下面的“Save”保存配置即可,之后在项目根目录下运行命令:mvn deploy


mvn deploy:会自动编译、打包、上传构件到私服,整个过程一键搞定!!


附件:

经常使用的几个比较快的镜像:

<mirrors>    <!-- 私服--><mirror><id>nexus</id><mirrorOf>nexus</mirrorOf><url>http://168.10.132.150:8081/nexus/content/groups/public/</url></mirror> <mirror>        <id>repo2</id>        <mirrorOf>central</mirrorOf>        <name>Human Readable Name for this Mirror.</name>        <url>http://repo2.maven.org/maven2/</url>    </mirror>        <mirror>        <id>ui</id>        <mirrorOf>central</mirrorOf>        <name>Human Readable Name for this Mirror.</name>        <url>http://uk.maven.org/maven2/</url>    </mirror>    <mirror>        <id>ibiblio</id>        <mirrorOf>central</mirrorOf>        <name>Human Readable Name for this Mirror.</name>        <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>    </mirror><mirror><id>alimaven</id><name>aliyun maven</name><url>http://maven.aliyun.com/nexus/content/groups/public/</url><mirrorOf>central</mirrorOf> </mirror><mirror><id>repo1</id><mirrorOf>central</mirrorOf><!--<mirrorOf>*</mirrorOf>--><url>https://repo1.maven.org/maven2/</url></mirror><mirror><id>sprintio</id><mirrorOf>central</mirrorOf><name>Human Readable Name for this Mirror.</name><url>https://repo.spring.io/libs-snapshot/</url></mirror>    <mirror>        <id>jboss-public-repository-group</id>        <mirrorOf>central</mirrorOf>        <name>JBoss Public Repository Group</name>        <url>http://repository.jboss.org/nexus/content/groups/public</url>    </mirror>  </mirrors>


0 0
原创粉丝点击