maven target 怎么运行 找不到或无法加载主类

如题所述

解决这个问题操作步骤如下:

在项目上右键 build path  -->  configure build  path 

上述5步完成后就ok了

温馨提示:内容为网友见解,仅供参考
第1个回答  2018-02-16

    确定项目中有public static void main(String[] args)方法

    在pom.xml中使用插件org.apache.maven.plugins.maven-shade-plugin,并在其配置中指明主类的位置,具体是在<mainClass>hello.HelloWorld</mainClass>处定义主类的位置。

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>hello.HelloWorld</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

相似回答