且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Maven错误:无法找到或加载主类

更新时间:2022-05-27 01:56:59

除非你因为设置mainClass而不需要'maven-assembly-plugin',否则你可以使用' maven-jar-plugin '插件。

Unless you need the 'maven-assembly-plugin' for reasons other than setting the mainClass, you could use the 'maven-jar-plugin' plugin.

     <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <index>true</index>
                    <manifest>
                        <mainClass>your.package.yourprogram.YourMainClass</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
     </plugins>

您可以在 ATLauncher

'mainClass'元素应该设置为您拥有程序入口点的类,例如:

The 'mainClass' element should be set to the class that you have the entry point to your program in eg:

package your.package.yourprogram;

public class YourMainClass {

    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}