Maven package error: An attached artifact must have a different ID than its corresponding main artifact

后端 未结 4 955
你的背包
你的背包 2021-02-19 16:24

Geting this error on: mvn package

It fails to build every time with the same error, I\'ve tried renaming the artifact, as well as changing dependencies for build in the

相关标签:
4条回答
  • 2021-02-19 16:57

    As Dimitri suggested, I solved this by adding classifier to spring-boot-maven-plugin:

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <classifier>boot</classifier>
        </configuration>
    </plugin>
    
    0 讨论(0)
  • 2021-02-19 17:06

    I am currently facing the same issue. However, providing the required parameter finalName, I can see that the .war file is well boot-ified. Please note that I still encounter the error message in both cases (with and without the finalName).

    Here is the link to the issue I opened on the Spring Boot project: https://github.com/spring-projects/spring-boot/issues/2060

    0 讨论(0)
  • 2021-02-19 17:15

    Looks like a bug in spring-boot-maven-plugin together with your version of Maven.

    As far as I can tell, Maven knows that the WAR plugin will generate the file target/compiled-1.0-SNAPSHOT.war. when it asks the spring-boot-maven-plugin for its output, it will get the same name. Since Maven doesn't know what the plugin does, it will assume that both are configured to create the same output file and stop since that can't be what you want (the files will overwrite each other).

    Try with the latest version of Maven or file a bug against the spring-boot-maven-plugin. Let them know which version of Maven you're using.

    0 讨论(0)
  • 2021-02-19 17:19

    All that is required is to include a <finalName> tag in the build section.

    <build>
        <finalName>myJar</finalName>
    </build>
    
    0 讨论(0)
提交回复
热议问题