2014-09-29 42 views
13

葛亭上的這個錯誤:MVN包Maven的包錯誤:一個連接神器必須有不同的ID比其相應的主神器

它無法每次都建設有同樣的錯誤,我已經試過重新命名的神器,以及更改在pom文件中構建的依賴關係。請參閱下面的更多細節:

任何幫助將非常感激。 錯誤:

[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2.599 s 
[INFO] Finished at: 2014-09-29T14:49:45+01:00 
[INFO] Final Memory: 33M/379M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.1.7.RELEASE:repackage (default) on project compiled: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.1.7.RELEASE:repackage failed: For artifact {com.phil-hudson:compiled:1.0-SNAPSHOT:war}: An attached artifact must have a different ID than its corresponding main artifact. -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException 

Process finished with exit code 1 

的pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<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.phil-hudson</groupId> 
    <artifactId>compiled</artifactId> 
    <version>1.0-SNAPSHOT</version> 

    <packaging>war</packaging> 

    <properties> 

    <!-- Generic properties --> 
    <java.version>1.8</java.version> 

    </properties> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.1.5.RELEASE</version> 
    </parent> 
    <dependencies> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>com.fasterxml.jackson.core</groupId> 
      <artifactId>jackson-databind</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.commons</groupId> 
      <artifactId>commons-lang3</artifactId> 
      <version>3.3.2</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>javax.inject</groupId> 
      <artifactId>javax.inject</artifactId> 
      <version>1</version> 
     </dependency> 

     <dependency> 
      <groupId>com.wordnik</groupId> 
      <artifactId>swagger-jaxrs_2.10</artifactId> 
      <version>1.3.2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codehaus.jackson</groupId> 
      <artifactId>jackson-mapper-asl</artifactId> 
      <version>1.9.13</version> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.xml.bind</groupId> 
      <artifactId>jaxb-core</artifactId> 
      <version>2.2.8-b01</version> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.xml.bind</groupId> 
      <artifactId>jaxb-impl</artifactId> 
      <version>2.2-promoted-b65</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.tomcat</groupId> 
      <artifactId>tomcat-servlet-api</artifactId> 
      <version>8.0.12</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet.jsp</groupId> 
      <artifactId>jsp-api</artifactId> 
      <version>2.1</version> 
      <scope>provided</scope> 
     </dependency> 

    </dependencies> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
       <version>1.1.7.RELEASE</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>repackage</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.3</version> 
       <configuration> 
        <warName>disney-product-feed</warName> 
       </configuration> 
      </plugin> 

     </plugins> 
    </build> 

    <repositories> 
     <repository> 
      <id>spring-releases</id> 
      <url>http://repo.spring.io/libs-release</url> 
     </repository> 
    </repositories> 

    <pluginRepositories> 
     <pluginRepository> 
      <id>spring-releases</id> 
      <url>http://repo.spring.io/libs-release</url> 
     </pluginRepository> 
    </pluginRepositories> 


</project> 

MVN依賴性:樹

[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.1.5.RELEASE:compile 
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.1.5.RELEASE:compile 
[INFO] | | +- org.springframework.boot:spring-boot:jar:1.1.5.RELEASE:compile 
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.1.5.RELEASE:compile 
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.1.5.RELEASE:compile 
[INFO] | | | +- org.slf4j:jcl-over-slf4j:jar:1.7.7:compile 
[INFO] | | | +- org.slf4j:jul-to-slf4j:jar:1.7.7:compile 
[INFO] | | | +- org.slf4j:log4j-over-slf4j:jar:1.7.7:compile 
[INFO] | | | \- ch.qos.logback:logback-classic:jar:1.1.2:compile 
[INFO] | | |  \- ch.qos.logback:logback-core:jar:1.1.2:compile 
[INFO] | | \- org.yaml:snakeyaml:jar:1.13:runtime 
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.1.5.RELEASE:compile 
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:7.0.54:compile 
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:7.0.54:compile 
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:7.0.54:compile 
[INFO] | +- org.hibernate:hibernate-validator:jar:5.0.3.Final:compile 
[INFO] | | +- javax.validation:validation-api:jar:1.1.0.Final:compile 
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.1.1.GA:compile 
[INFO] | | \- com.fasterxml:classmate:jar:1.0.0:compile 
[INFO] | +- org.springframework:spring-core:jar:4.0.6.RELEASE:compile 
[INFO] | \- org.springframework:spring-webmvc:jar:4.0.6.RELEASE:compile 
[INFO] |  \- org.springframework:spring-expression:jar:4.0.6.RELEASE:compile 
[INFO] +- org.springframework:spring-web:jar:4.0.6.RELEASE:compile 
[INFO] | +- org.springframework:spring-aop:jar:4.0.6.RELEASE:compile 
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile 
[INFO] | +- org.springframework:spring-beans:jar:4.0.6.RELEASE:compile 
[INFO] | \- org.springframework:spring-context:jar:4.0.6.RELEASE:compile 
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.3.3:compile 
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.3:compile 
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.3.3:compile 
[INFO] +- org.apache.commons:commons-lang3:jar:3.3.2:compile 
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.1.5.RELEASE:compile 
[INFO] | +- junit:junit:jar:4.11:compile 
[INFO] | +- org.mockito:mockito-core:jar:1.9.5:compile 
[INFO] | | \- org.objenesis:objenesis:jar:1.0:compile 
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:compile 
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:compile 
[INFO] | \- org.springframework:spring-test:jar:4.0.6.RELEASE:compile 
[INFO] +- javax.inject:javax.inject:jar:1:compile 
[INFO] +- com.wordnik:swagger-jaxrs_2.10:jar:1.3.2:compile 
[INFO] | +- org.scala-lang:scala-library:jar:2.10.0:compile 
[INFO] | +- com.wordnik:swagger-core_2.10:jar:1.3.2:compile 
[INFO] | | +- commons-lang:commons-lang:jar:2.4:compile 
[INFO] | | +- org.slf4j:slf4j-api:jar:1.7.7:compile 
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-scala_2.10:jar:2.1.5:compile 
[INFO] | | | +- com.thoughtworks.paranamer:paranamer:jar:2.3:compile 
[INFO] | | | \- org.scala-lang:scala-reflect:jar:2.10.0:compile 
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-jsonSchema:jar:2.1.0:compile 
[INFO] | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.0.0:compile 
[INFO] | | | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.0.0:compile 
[INFO] | | +- com.wordnik:swagger-annotations:jar:1.3.2:compile 
[INFO] | | +- org.json4s:json4s-ext_2.10:jar:3.2.4:compile 
[INFO] | | | +- joda-time:joda-time:jar:2.3:compile 
[INFO] | | | \- org.joda:joda-convert:jar:1.2:compile 
[INFO] | | +- org.json4s:json4s-native_2.10:jar:3.2.4:compile 
[INFO] | | | \- org.json4s:json4s-core_2.10:jar:3.2.4:compile 
[INFO] | | |  +- org.json4s:json4s-ast_2.10:jar:3.2.4:compile 
[INFO] | | |  \- org.scala-lang:scalap:jar:2.10.0:compile 
[INFO] | | |  \- org.scala-lang:scala-compiler:jar:2.10.0:compile 
[INFO] | | \- org.json4s:json4s-jackson_2.10:jar:3.2.4:compile 
[INFO] | +- javax.ws.rs:jsr311-api:jar:1.1.1:compile 
[INFO] | \- org.reflections:reflections:jar:0.9.8:compile 
[INFO] |  +- com.google.guava:guava:jar:11.0.2:compile 
[INFO] |  | \- com.google.code.findbugs:jsr305:jar:1.3.9:compile 
[INFO] |  +- javassist:javassist:jar:3.12.1.GA:compile 
[INFO] |  \- dom4j:dom4j:jar:1.6.1:compile 
[INFO] |  \- xml-apis:xml-apis:jar:1.0.b2:compile 
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile 
[INFO] | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile 
[INFO] +- com.sun.xml.bind:jaxb-core:jar:2.2.8-b01:compile 
[INFO] | +- javax.xml.bind:jaxb-api:jar:2.2.9:compile 
[INFO] | \- com.sun.istack:istack-commons-runtime:jar:2.16:compile 
[INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.2-promoted-b65:compile 
[INFO] +- org.apache.tomcat:tomcat-servlet-api:jar:8.0.12:compile 
[INFO] \- javax.servlet.jsp:jsp-api:jar:2.1:provided 
+0

我認爲這是特定於spring-boot-maven-plugin而不是一般的maven問題。以防萬一,運行'mvn dependency:tree',然後查看是否有名稱衝突的工件。 – Freiheit 2014-09-29 14:14:59

+0

謝謝你,我跑了它,它看起來對我來說沒問題..我更新了我的問題與輸出。 – 2014-09-29 14:34:49

回答

7

spring-boot-maven-plugin與你的Maven的版本一起看起來像一個bug。

據我所知,Maven知道WAR插件會生成文件target/compiled-1.0-SNAPSHOT.war。當它詢問spring-boot-maven-plugin的輸出時,它將得到相同的名稱。由於Maven不知道插件的功能,因此它會假設兩者都被配置爲創建相同的輸出文件並停止,因爲這不能成爲您想要的(文件將相互覆蓋)。

使用Maven的最新版本嘗試或對spring-boot-maven-plugin提交錯誤報告。讓他們知道你正在使用哪個版本的Maven。

+3

是的,我只是擺脫了Spring WAR插件,它的工作,一定有一些衝突,但它沒有很好地處理日誌。 – 2014-09-29 15:07:18

2

我目前面臨同樣的問題。 但是,提供所需參數finalName,我可以看到.war文件啓動良好。 請注意,在這兩種情況下(有和沒有finalName)我仍然遇到錯誤消息。

這裏是鏈接到我的春天啓動項目開盤的問題:https://github.com/spring-projects/spring-boot/issues/2060

13

正如迪米特里建議,我解決了這個加classifier去春來,啓動了Maven插件:

<plugin> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-maven-plugin</artifactId> 
    <configuration> 
     <classifier>boot</classifier> 
    </configuration> 
</plugin> 
1

所有這一切都需要在build部分包含一個<finalName>標籤。

<build> 
    <finalName>myJar</finalName> 
</build>