我有一個多模塊 spring-boot 項目,在我的應用程序的集成測試之前,我啟動了另一個子模塊(它是由另一個 spring boot 應用程序制作的存根)你可以看到它附加到“預集成測試”,它是最后工作正常。 Parent Pom| |----myRealApp module(spring boot app)|----stub module(This is also a spring-boot app)我的問題是,有沒有辦法隨機化并共享此端口(未固定為 8090),因此 Jenkins 服務器上的并發構建可以運行測試并且不會失敗,因為地址已在使用中。我知道我可以在 spring 屬性文件中生成隨機數/端口。但是找不到將其傳遞給 Pom 的方法。application-test.properties myRealApp的: stub.port=8090 stub.url=http://localhost:${stub.port}/stub/api/v1/domains/myRealApp 的 Pom: <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>${spring.boot.mainclass}</mainClass> </configuration> <executions> <execution> <id>start-stub</id> <configuration> <arguments> <argument>--server.port=8090</argument> </arguments> <mainClass>io.swagger.Stub</mainClass> <classesDirectory>../my-stub/target/classes</classesDirectory> </configuration> <goals> <goal>start</goal> </goals> <phase>pre-integration-test</phase> </execution> <execution> <goals> <goal>build-info</goal> </goals> </execution> </executions> </plugin>
添加回答
舉報
0/150
提交
取消