首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

maven 自动公布更新本地和远程仓库

2012-12-21 
maven 自动发布更新本地和远程仓库$ mvn install -Dmaven.test.skiptrue mvn clean package deploy -Dmav

maven 自动发布更新本地和远程仓库

$ mvn install -Dmaven.test.skip=true

mvn clean package deploy -Dmaven.test
.skip=true

?

    本地仓的更新mvn? clean package install
    远程的更新mvn clean package deploy工程文件pom.xml的设置

??? <build>
?? ??? ?<pluginManagement>
?? ??? ??? ?<plugins>
?? ??? ??? ??? ?<plugin>
?? ??? ??? ??? ??? ?<groupId>org.apache.maven.plugins</groupId>
?? ??? ??? ??? ??? ?<artifactId>maven-compiler-plugin</artifactId>
?? ??? ??? ??? ??? ?<configuration>
?? ??? ??? ??? ??? ??? ?<source>1.5</source>
?? ??? ??? ??? ??? ??? ?<target>1.5</target>
?? ??? ??? ??? ??? ?</configuration>
?? ??? ??? ??? ?</plugin>
?? ??? ??? ?</plugins>
?? ??? ?</pluginManagement>
?? ??? ?<extensions>
?? ??? ??? ?<extension>
?? ??? ??? ??? ?<groupId>org.apache.maven.wagon</groupId>
?? ??? ??? ??? ?<artifactId>wagon-ftp</artifactId>
?? ??? ??? ??? ?<version>1.0-alpha-6</version>
?? ??? ??? ?</extension>
?? ??? ?</extensions>
?? ?</build>

??? <repositories>
?? ??? ?<repository>
?? ??? ??? ?<id>cdc-respository</id>
?? ??? ??? ?<name>cdc-respository</name>
?? ??? ??? ?<url>http://xxx.xxx.xxx.xx:8080/Maven2Repository</url>
?? ??? ?</repository>
?? ?</repositories>
?? ?<pluginRepositories>
?? ??? ?<pluginRepository>
?? ??? ??? ?<id>cdc-plugin-respository</id>
?? ??? ??? ?<name>cdc-plugin-respository</name>
?? ??? ??? ?<url>http://xxx.xxx.xxx.xxx:8080/Maven2Repository</url>
?? ??? ?</pluginRepository>
?? ?</pluginRepositories>

?? ?<distributionManagement>
?? ??? ?<repository>
?? ??? ??? ?<id>my-deploy-respository</id>
?? ??? ??? ?<name>cdc-plugin-respository</name>
?? ??? ??? ?<url>ftp://192.168.2.177/home/mfguser/Maven2Repository</url>
?? ??? ?</repository>
?? ?</distributionManagement>

    ?本地用户setting.xml文件的设定?? /root/.m2/settings.xml

???? <server>
????? <id>my-deploy-respository</id>
????? <username>user</username>
????? <password>password</password>
??? </server>

?

?

?

?

?

?

?

?

?

评论(0) 收藏 举报

提交到nexus时候报错:

?

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project *: Failed to deploy artifacts: Could not transfer artifact *:jar:1.0 from/to releases (http://10.1.81.199:8081/nexus/content/repositories/releases/): Failed to transfer file:?http://10.1.81.199:8081/nexus/content/repositories/releases/com/cs2c/security-management-client*?/1.0/*-1.0.jar. Return code is: 401, ReasonPhrase:Unauthorized.

原来是没有配置认证。

?

maven目录conf的setting.xml里,

  1. ??<server>??????<id>releases</id>??
  2. ????<username>admin</username>??????<password>admin123</password>??
  3. ??</server>???<server>??
  4. ??<id>snapshots</id>????<username>admin</username>??
  5. ??<password>admin123</password>????</server>??
  6. </servers>??

用户名和密码都是nexus的。再次deploy即可。

注意这里的id要和pom.xml里远程deploy的地址对应一致,我的pom.xml里配置:

  1. <!--?配置远程发布到私服,mvn?deploy?-->??????<distributionManagement>??
  2. ????????<repository>??????????????<id>releases</id>??
  3. ????????????<name>Nexus?Release?Repository</name>??????????????<url>http://10.1.81.199:8081/nexus/content/repositories/releases/</url>??
  4. ????????</repository>??????????<snapshotRepository>??
  5. ????????????<id>snapshots</id>??????????????<name>Nexus?Snapshot?Repository</name>??
  6. ????????????<url>http://10.1.81.199:8081/nexus/content/repositories/snapshots/</url>??????????</snapshotRepository>??
  7. ????</distributionManagement>??




如果这里不配置,会报错:报错:Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project git-demo: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter

热点排行