Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting multiple Spring Boot apps from Maven

To do a chain test over a several micro services components I want to start multiple microservices (created using Spring Boot) before running the tests.

Root
|
+  microservice A
|
+  microservice B
|
+  microservice C
|
+  integration tests

I tried to run 'spring-boot:start' multiple times in the pre-integration-test phase from the integration test module, but I could not get this working. So I do have two questions:

  • Is there a way to start/stop a spring boot jar from another submodule using the spring-boot-maven-plugin?
  • Or, is there another way to start multiple components in the pre-integration-test phase?
like image 649
Marc Enschede Avatar asked Mar 12 '26 14:03

Marc Enschede


1 Answers

It took some time, but I got it working using the following plugin settings

        <plugin>
            <groupId>com.bazaarvoice.maven.plugins</groupId>
            <artifactId>process-exec-maven-plugin</artifactId>
            <version>0.7</version>
            <executions>
                <execution>
                    <id>frontend</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start</goal>
                    </goals>
                    <configuration>
                        <name>run-server</name>
                        <waitForInterrupt>false</waitForInterrupt>
                        <healthcheckUrl>http://localhost:8082/actuator/health</healthcheckUrl>
                        <arguments>
                            <argument>java</argument>
                            <argument>-jar</argument>
                            <argument>${project.build.directory}/frontend.jar</argument>
                        </arguments>
                    </configuration>
                </execution>

                <execution>
                    <id>frontend2</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start</goal>
                    </goals>
                    <configuration>
                        <name>run-server</name>
                        <waitForInterrupt>false</waitForInterrupt>
                        <healthcheckUrl>http://localhost:8083/actuator/health</healthcheckUrl>
                        <arguments>
                            <argument>java</argument>
                            <argument>-jar</argument>
                            <argument>${project.build.directory}/frontend2.jar</argument>
                        </arguments>
                    </configuration>
                </execution>

                <execution>
                    <id>backendservice</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start</goal>
                    </goals>
                    <configuration>
                        <name>run-server</name>
                        <waitForInterrupt>false</waitForInterrupt>
                        <healthcheckUrl>http://localhost:8081/actuator/health</healthcheckUrl>
                        <arguments>
                            <argument>java</argument>
                            <argument>-jar</argument>
                            <argument>${project.build.directory}/backendservice.jar</argument>
                        </arguments>
                    </configuration>
                </execution>

                <execution>
                    <id>stop-server</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop-all</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
like image 117
Marc Enschede Avatar answered Mar 15 '26 05:03

Marc Enschede



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!