2011-05-06 21 views
57

我试图运行命令,mvn release:perform,但我得到这个错误:Maven:仓库元素没有在distributionManagement中的POM中指定?

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

这是我的pom.xml文件:

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
     <modelVersion>4.0.0</modelVersion> 
     <groupId>com.sonatype.blog</groupId> 
     <artifactId>git-demo</artifactId> 
     <packaging>jar</packaging> 
     <version>1.1-SNAPSHOT</version> 
     <name>git-demo</name> 
     <url>http://maven.apache.org</url> 
     <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.1</version> 
      <scope>test</scope> 
     </dependency> 
     </dependencies> 

     <scm> 
     <connection>scm:git:[email protected]:Christian-Achilli-KP/git-demo.git</connection> 
     <url>scm:git:[email protected]:Christian-Achilli-KP/git-demo.git</url> 
     <developerConnection>scm:git:[email protected]:Christian-Achilli-KP/git-demo.git</developerConnection> 
     </scm> 

    <distributionManagement> 
    <!-- use the following if you're not using a snapshot version. --> 
    <repository> 
     <id>localSnap</id> 
     <name>RepositoryProxyRel</name> 
     <url>http://127.0.0.1:8080/nexus/content/repositories/releases/</url> 
    </repository> 
    <!-- use the following if you ARE using a snapshot version. --> 
    <snapshotRepository> 
     <id>MylocalSnap</id> 
     <name>RepositoryProxySnap</name> 
     <url>http://127.0.0.1:8080/nexus/content/repositories/snapshots/</url> 
    </snapshotRepository> 
</distributionManagement>  
    <build> 
     <plugins> 
      <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-release-plugin</artifactId> 
      <version>2.1</version> 
      </plugin> 
     </plugins> 
     </build> 

</project> 

其实我可以看到

repository

声明里面的

distributionManagent

标记。

这里是我的settings.xml

<settings> 
<servers> 
     <server> 
      <id>localSnap</id> 
      <username>deployment</username> 
      <password>****</password> 
     </server> 

     <server> 
      <id>MylocalSnap</id> 
      <username>deployment</username> 
      <password>****</password> 
     </server> 

    <server> 
     <id>myserver</id> 
     <username>tomcat</username> 
     <password>tomcat</password> 
    </server> 


    </servers> 





<mirrors> 
    <mirror> 
     <!--This sends everything else to /public --> 
     <id>nexus</id> 
     <mirrorOf>*</mirrorOf> 
     <url>http://127.0.0.1:8080/nexus/content/groups/public/</url> 
    </mirror> 
    </mirrors> 


    <profiles> 

    <profile> 
     <id>nexus</id> 
     <properties> 

     <project.build.sourceEncoding>MacRoman</project.build.sourceEncoding> 

     <project.reporting.outputEncoding>MacRoman</project.reporting.outputEncoding> 

     </properties> 




     <!--Enable snapshots for the built in central repo to direct --> 
     <!--all requests to nexus via the mirror --> 
     <repositories> 

     <repository> 
      <id>central</id> 
      <url>http://central</url> 
      <releases><enabled>true</enabled></releases> 
      <snapshots><enabled>true</enabled></snapshots> 
     </repository> 
     </repositories> 
    <pluginRepositories> 
     <pluginRepository> 
      <id>central</id> 
      <url>http://central</url> 
      <releases><enabled>true</enabled></releases> 
      <snapshots><enabled>true</enabled></snapshots> 
     </pluginRepository> 
     </pluginRepositories> 
    </profile> 

    </profiles> 

    <activeProfiles> 
    <activeProfile>nexus</activeProfile> 
    </activeProfiles> 

</settings> 

任何意见,为什么抱怨?

+0

你打电话MVN发布:准备之前?和coure有相同的Id,它不会工作了。 – khmarbaise 2011-05-06 10:41:43

+0

@khmarbaise是的,我确实调用了mvn:release并更改了id。我将用新POM更新问题 – 2011-05-06 13:03:04

+0

您是否添加了.gitignore来忽略目标文件夹?你可以推动更新github,我可以看看? – khmarbaise 2011-05-06 13:34:50

回答

2

两个回购券的ID均为localSnap;这可能不是你想要的,它可能会混淆Maven。

如果不是这样:POM中可能会有更多repository元素。搜索mvn help:effective-pom的输出为repository以确保它们的数量和位置符合您的预期。

+0

谢谢,我尝试了你们两个的建议,但我无法想出一个可行的解决方案。在有效的POM中,确实存在另一个带有标签的地方,但它不包含任何与标签中的内容相冲突的地方。这里有一个类似的问题http://stackoverflow.com/questions/4539917/repository-element,但我没有得到答案,它是如何适合这个问题! – 2011-05-06 12:57:27

+1

这是一个多模块构建?如果是这样,请检查父POM和版本。也许你忘了更新版本号,一个模块仍在使用旧的父POM。 – 2011-05-09 07:38:10

29

查看target/checkout/中的pom.xml文件。机会是,您的干线或主分支中的pom.xml没有distributionManagement标记。

+1

一个'干净'然后重试解决这个给我。 – 2014-04-25 23:12:33

7

我收到了同样的消息(“repository元素没有在distributionManagement元素中的POM中指定”)。我检查了/target/checkout/pom.xml,并根据另一个答案,它真的缺少<distributionManagement>

原来问题是在我的主分支(使用git)的pom.xml中丢失。

清理(mvn release:rollbackmvn cleanmvn release:cleangit tag -d v1.0.0)后,我再次运行mvn release和它的工作。

3

您还可以覆盖在命令行上部署库: -Darguments=-DaltDeploymentRepository=myreposid::default::http://my/url/releases

0

对我来说,这是一个缺少版本我的神器简单的东西 - “1.1-SNAPSHOT”