解決:single failed: For artifact {null:null:null:jar}: The groupId cannot be empty. 把工程依賴的jar包打到入jar中

1. 執行 mvn clean install 報錯:

Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.4.1:single failed: For artifact {null:null:null:jar}: The groupId cannot be empty.

2. 我只是想把工程依賴的jar包打到 最後的jar包中。

pom 中加上配置,會生成2個 jar ,用帶有依賴的那個 jar 就行。( 如下文中的xxx-0.0.1-SNAPSHOT-jar-with-dependencies.jar )

          <plugin>
                <artifactId>maven-assembly-plugin</artifactId>                
                <version>3.3.0</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id> <!-- this is used for inheritance merges -->
                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                            <goal>singles</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

3. 特別注意:版本一定要是3.3.0,或者查官網找最新文檔中的版本。我之前用的是2.4.1,就一直報如題的錯。

只是改爲官方文檔上的版本就可。文檔地址:http://maven.apache.org/plugins/maven-assembly-plugin/usage.html

生成的jar 如:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章