How to Configure pom.xml to run 2 java mains in 1 Maven project

后端 未结 1 605
日久生厌
日久生厌 2021-01-14 14:15

I have a Maven project and it has 2 mains (MyTestApp_A, and MyTestApp_B) inside one of the packages from the src folder.

I can run these \"main\" classes in Eclipse

相关标签:
1条回答
  • 2021-01-14 14:27

    Try using executions for each main class you want to execute:

    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <id>MyTestApp_A</id>
                    <goals>
                        <goal>java</goal>
                    </goals>
                    <configuration>
                        <mainClass>servers.MyTestApp_A</mainClass>
                        <includePluginDependencies>false</includePluginDependencies>
                    </configuration>
                </execution>
                <execution>
                    <id>MyTestApp_B</id>
                    <goals>
                        <goal>java</goal>
                    </goals>
                    <configuration>
                        <mainClass>servers.MyTestApp_B</mainClass>
                        <includePluginDependencies>false</includePluginDependencies>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
    
    0 讨论(0)
提交回复
热议问题