How to configure pom.xml to run 2 java backbones in 1 Maven project

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

I can run these “core” classes in Eclipse if I open them and press the start button. However, Eclipse is bugged, and so I really need to run these two classes on the command line using Maven.

I have not used Maven before, but after I asked for help and did some research, I understand that I need to modify the pom.xml file.

Therefore, I successfully modified my pom.xml file to start one of the applications using the command mvn exec:java -Dexec.mainClass="servers.MyTestApp_B":

    <plugins>
        <!-- Allows the example to be run via 'mvn compile exec:java' -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>

            <configuration>
                <mainClass>servers.MyTestApp_A</mainClass>
                <includePluginDependencies>false</includePluginDependencies>
            </configuration>


        </plugin>

    </plugins>

Happy to be able to run MyTestApp_A, I tried to add another part of the configuration to run MyTestApp_B:

    <plugins>
        <!-- Allows the example to be run via 'mvn compile exec:java' -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>

            <configuration>
                <mainClass>servers.MyTestApp_A</mainClass>
                <includePluginDependencies>false</includePluginDependencies>
            </configuration>
            <configuration>
                <mainClass>servers.MyTestApp_B</mainClass>
                <includePluginDependencies>false</includePluginDependencies>
            </configuration>

        </plugin>

    </plugins>

. -, 2 <configuration> pom.xml.

, MyTestApp_A MyTestApp_B Maven? pom.xml?

+3
1

, :

<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>
+6

Source: https://habr.com/ru/post/1652803/


All Articles