在打包阶段执行 assembly:single 个目标

Execute assembly:single goal during package phase

下面是pom.xml。当我用 mvn package 尝试 运行 时,fat jar 没有生成。但是 mvn assembly:single 构建了 fat jar。

我做错了什么?

<build>
    <sourceDirectory>src</sourceDirectory>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                    <manifest>
                    <mainClass>com.xyz.main.MainHandler</mainClass>
                    </manifest>
                    </archive>
                    <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                    <goal>single</goal>
                    </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

因此,从 pluginManagement 标签中删除 maven-assembly-plugin 后,它起作用了。

需要清晰度检查 this