我正在尝试在预集成阶段启动一个spring引导应用程序,并对其运行一些集成测试。
下面是配置,在fork模式false中,我可以验证应用程序是否正在启动,但即使通过命令行或通过配置将fork设置为true,应用程序也不是在fork jvm中启动,而是在相同的jvm中启动。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.1.RELEASE</version>
<configuration>
<mainClass>com.settlement.Settlement</mainClass>
<layout>ZIP</layout>
<jvmArguments>
-DconfigDbPropertiesFile=../../common/profile/src/main/resources/${user.name}.properties -Dsettlement.rest.port=9090 -DcomponentPort=1779
</jvmArguments>
<fork>true</fork>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
<execution>
<id>start-service</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-service</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>要执行的命令
mvn spring-boot:run -Dspring-boot.run.arguments=Settlement,Settlement,Settlement,BASE_PERSISTENCE_CONSTANTS -Dspring-boot.run.fork=true发布于 2019-12-09 22:41:03
这段maven代码适用于我。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
<executions>
<execution>
<configuration>
<mainClass>com.ashomokdev.springdockerec2.SpringDockerEc2Application</mainClass>
</configuration>
</execution>
</executions>
</plugin>https://stackoverflow.com/questions/53793995
复制相似问题