Running Integration Tests with Maven verify (./mvnw verify) fails using the Spring Boot Maven Plugin.
Spring Boot 3.4.6 Java 21
This fails because it relies on an MBean Server running.
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.4.2:start (pre-integration-test) on project application-name: Failed to connect to MBean server at port 9001: Could not invoke shutdown operation: Connection refused to host: 127.0.0.1; nested exception is:
[ERROR] java.net.ConnectException: Connection refused: connect
[ERROR] -> [Help 1]
I am using the pre and post executions on the spring-boot-maven-plugin, since springdoc-openapi-maven-plugin needs it to generate the openapi.json.
Is there any way to avoid it to rely on an MBean server?
I have tried to disable JMX, but it did not work.
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<apiDocsUrl>http://localhost:8088/actuator/openapi/${project.artifactId}</apiDocsUrl>
<outputFileName>openapi.json</outputFileName>
</configuration>
<executions>
<execution>
<id>generate-openapi</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>-Dspring.profiles.active=it</jvmArguments>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
<image>
<builder>paketobuildpacks/builder-jammy-tiny</builder>
<name>${docker.publishRegistry.url}/${project.name}:${project.version}</name>
<createdDate>${maven.build.timestamp}</createdDate>
<cleanCache>true</cleanCache>
<env>
<BP_NATIVE_IMAGE>false</BP_NATIVE_IMAGE>
<BP_JVM_VERSION>${java.version}</BP_JVM_VERSION>
<BP_OCI_SOURCE>${project.scm.url}</BP_OCI_SOURCE>
<BP_OCI_CREATED>${maven.build.timestamp}</BP_OCI_CREATED>
<BP_OCI_VERSION>${project.version}</BP_OCI_VERSION>
<BP_OCI_DESCRIPTION>${project.description}</BP_OCI_DESCRIPTION>
</env>
</image>
</configuration>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
For running the integration tests I could use maven-failsafe-plugin instead, and remove the pre/post integration-test executions from spring-boot-maven-plugin. It will run the integration tests **/*IT.java
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<argLine>-Dspring.profiles.active=it</argLine>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
However then I will not be able to generate the openapi during the build.