Maven & Java: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java are missing or invalid

前端 未结 5 1452
清酒与你
清酒与你 2020-12-03 06:52

My Java EE proj builds fine, but when trying to execute get following error:

gert@gert-VirtualBox:~/workspace/CDBOOKSTORE$ mvn exec:java 
[INFO] Scanning for         


        
相关标签:
5条回答
  • 2020-12-03 07:19

    If the <configuration> is outside the <executions> , it is the configuration for the plugin to be used no matter what the life-cycle phase is.

    If the <configuration> is inside the <executions>, it is the configuration to be used in certain life-cycle phase.

    As Vabis has suggested, use mvn exec:java@someID to execute the specific execution of the goal for a plugin.

    For more information, please see https://maven.apache.org/guides/mini/guide-configuring-plugins.html.

    0 讨论(0)
  • 2020-12-03 07:36

    There is no such parameter like mainClass in exec-maven-plugin, try to use:

    <configuration>
       <executable>java</executable>
       <arguments>
         <argument>-classpath</argument>
         <classpath/>
         <argument>org.aptovia.javaee7.CDBOOKSTORE.Main</argument>
       </arguments>
    </configuration>
    
    0 讨论(0)
  • 2020-12-03 07:38

    "configuration" must go outside "executions", like this:

    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>java</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <mainClass>com.emilio.App</mainClass>
            </configuration>
        </plugin>
    </plugins>
    
    0 讨论(0)
  • 2020-12-03 07:41

    Configuration seems correct with missing id parameter inside execution part. Proper way would be:

    <executions>
        <execution>
            <id>someID</id>
            <goals>
                <goal>java</goal>
            </goals>
            <configuration>
                <mainClass>org.aptovia.javaee7.CDBOOKSTORE.Main</mainClass>
            </configuration>
        </execution>
    </executions>
    

    Assuming you are running main method using maven, execution would be like below:

    mvn exec:java@someID

    someID added inside execution part.

    0 讨论(0)
  • 2020-12-03 07:42

    Make sure you execute the mvn exec:java from within the same directory where your pom.xml with exec configuration resides.

    0 讨论(0)
提交回复
热议问题