Maven包错误:附加工件必须具有与其对应的主工件不同的ID

时间:2014-09-29 13:56:51

标签: java spring maven

获取此错误:mvn package

每次都无法使用相同的错误进行构建,我尝试重命名工件,以及更改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

4 个答案:

答案 0 :(得分:13)

正如Dimitri建议的那样,我通过将classifier添加到spring-boot-maven-plugin解决了这个问题:

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

答案 1 :(得分:7)

与您的Maven版本一起看起来像spring-boot-maven-plugin中的错误。

据我所知,Maven知道WAR插件会生成文件target/compiled-1.0-SNAPSHOT.war。当它询问spring-boot-maven-plugin输出时,它会得到相同的名称。由于Maven不知道插件的作用,因此它会假设两者都配置为创建相同的输出文件并停止,因为它不是你想要的(文件将互相覆盖)。

尝试使用最新版本的Maven或针对spring-boot-maven-plugin提交错误。让他们知道您正在使用哪个版本的Maven。

答案 2 :(得分:2)

我目前面临同样的问题。 但是,提供所需的参数 finalName ,我可以看到.war文件很好地启动了。 请注意,在这两种情况下我都会遇到错误消息(包含和不包含 finalName )。

以下是我在Spring Boot项目中打开的问题的链接:https://github.com/spring-projects/spring-boot/issues/2060

答案 3 :(得分:1)

所需要的只是在SQL Error (1064): You have an error in your SQL syntax;部分添加<finalName>标记。

build