Maven Error: Could not find or load main class

后端 未结 12 1622
忘了有多久
忘了有多久 2020-12-05 07:09

I\'m using a Java Maven program and I don\'t know what to enter as the . I\'ve tried all kinds of things based off of numerous stackoverflow q

12条回答
  •  旧时难觅i
    2020-12-05 07:31

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

         
            
                org.apache.maven.plugins
                maven-jar-plugin
                2.4
                
                    
                        true
                        
                            your.package.yourprogram.YourMainClass
                        
                    
                
            
         
    

    You can see the plugin in practise in the ATLauncher.

    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");
        }
    }
    

提交回复
热议问题