maven发布到本地仓库,和私服
发布maven工程的时候,本地package,install等等都没问题,但是打包的时候就是报错,
eployment failed: repository element was not specified in the POM inside distributionManagement element or in - DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
意思是在pom文件中缺少distributionManagement标签,或者缺少-DaltDeployementRepositoty,说的是缺少deploy的地址,maven不知道你想要deploy到哪里,在pom文件中增加如下信息,就发布成功了. 发布到本地仓库 命令:install
<distributionManagement>
<repository>
<id>localRepository</id>
<url>file:D:/repository</url>
</repository>
</distributionManagement>
发布到私服 命令:deploy 第一步: 需要在客户端电脑上配置 maven环境,并修改 settings.xml 文件,配置连接私服的用户和密码 。此用户名和密码用于私服校验,因为私服需要知道上传都 的账号和密码 是否和私服中的账号和密码 一致。
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
第二步: 配置项目pom.xml 配置私服仓库的地址,本公司的自己的jar包会上传到私服的宿主仓库,根据工程的版本号决定上传到哪个宿主仓库,如果版本为release则上传到私服的release仓库,如果版本为snapshot则上传到私服的snapshot仓库 releases 连接发布版本项目仓库 snapshots 连接测试版本项目仓库 注意:pom.xml这里<id> 和 settings.xml 配置 <id> 对应!
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
