m2e shade eclipse “project main artifact does not exist”

允我心安 提交于 2019-12-03 22:15:13

[ERROR] The project main artifact does not exist. This could have the following

We were getting this problem recently. What resolved it for us was to not do mvn shade:shade but instead use:

mvn package

This does additional compilation and package work before running the shade plugin and so the main class was available on the classpath.

The shade plugin is attempting to include the project's artifact in the shaded JAR. Since it doesn't exist (yet), you're getting this error. You either need to build/package the project artifact first (e.g., by attaching the shade goal to the package phase)

If you don't have any project artifact to include in the shaded JAR, you can add an excludes node to remove the project's artifact.

Here's an example:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>1.6</version>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>shade</goal>
                </goals>
                <configuration>
                    <transformers>
                        <transformer
                            implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>com.group.id.Launcher1</mainClass>
                        </transformer>
                    </transformers>
                    <excludes>
                        <exclude>com.my.proj:AAA</exclude>
                    </excludes>
                </configuration>
            </execution>
        </executions>
    </plugin>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!