2011-05-06 20 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」