diff --git a/spring-boot-testjars/src/main/java/org/springframework/experimental/boot/server/exec/CommonsExecWebServerFactoryBean.java b/spring-boot-testjars/src/main/java/org/springframework/experimental/boot/server/exec/CommonsExecWebServerFactoryBean.java index 0d0763d..14af3c9 100644 --- a/spring-boot-testjars/src/main/java/org/springframework/experimental/boot/server/exec/CommonsExecWebServerFactoryBean.java +++ b/spring-boot-testjars/src/main/java/org/springframework/experimental/boot/server/exec/CommonsExecWebServerFactoryBean.java @@ -111,7 +111,9 @@ private CommonsExecWebServer build() { private String[] createSystemPropertyArgs() { Map systemPropertyArgs = new HashMap<>(this.systemProperties); systemPropertyArgs.put("PORTFILE", this.applicationPortFile.getAbsolutePath()); - systemPropertyArgs.put("server.port", "0"); + if (!systemPropertyArgs.containsKey("server.port")) { + systemPropertyArgs.put("server.port", "0"); + } return systemPropertyArgs.entrySet().stream().map((e) -> "-D" + e.getKey() + "=" + e.getValue() + "") .toArray(String[]::new); }