Skip to content

Property replacement does not work for management.server.port since spring-boot 2.1 #15354

@hdconradi

Description

@hdconradi

Consider the following patch against spring-boot-sample-webservices:

diff --git a/spring-boot-samples/spring-boot-sample-webservices/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-webservices/src/main/resources/application.properties
index 2453faa0be..c6a1571aed 100644
--- a/spring-boot-samples/spring-boot-sample-webservices/src/main/resources/application.properties
+++ b/spring-boot-samples/spring-boot-sample-webservices/src/main/resources/application.properties
@@ -1 +1,3 @@
+m1=12345
+management.server.port=${m1:0}
 spring.webservices.wsdl-locations=classpath:META-INF/schemas/

The maven build now breaks with

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.121 s <<< FAILURE! - in sample.webservices.SampleWsApplicationTests
[ERROR] testSendingHolidayRequest(sample.webservices.SampleWsApplicationTests)  Time elapsed: 0.001 s  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.lang.Integer] for value '${m1:0}'; nested exception is java.lang.NumberFormatException: For input string: "${m1:0}"
Caused by: java.lang.NumberFormatException: For input string: "${m1:0}"

This is the case at least since 2.1.0 and still does not work in 2.1.1.

Interestingly, this does only happen in the test.
The deployment start properly with java -jar spring-boot-sample-webservices-2.2.0.BUILD-SNAPSHOT.jar

Metadata

Metadata

Assignees

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions