You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an ApplicationContext hierarchy in our Spring Boot application, we notice that @PropertySource isn't working as before in our child applicationcontext.
My setup consists of 2 child contexts with each a simple RestController that will return "Hello World".
Each of these child contexts has their own Configuration that will fetch their properties using a @PropertySource annotation.
In these configurations files I configure a different server.port.
Context A will have port 8081 and Context B will have port 8082.
When using 2.3.0 it seems that these properties aren't correctly picked up as I see that both modules try to use port 8080 and I get the error: "Web server failed to start. Port 8080 was already in use.".
When downgrading to 2.2.7 this works as it should be and Context A will use port 8081 and Context B will use port 8082.
wilkinsona
changed the title
PropertySource not working in ApplicationContext Hierarchy when upgrading to 2.3.0
Configuring server.* properties in a child context has no effect in Spring Boot 2.3
Jun 9, 2020
Thanks very much for the sample. I've reproduced the problem.
The change in behaviour from 2.2 to 2.3 is due to ServerProperties being registered in the parent context in 2.3 due to this change. When a configuration properties bean is present in the parent context it isn't registered in the child. As a result, your child contexts see the server configuration from the parent as they no longer register their own ServerProperties beans.
When using an ApplicationContext hierarchy in our Spring Boot application, we notice that
@PropertySource
isn't working as before in our child applicationcontext.My setup consists of 2 child contexts with each a simple
RestController
that will return "Hello World".Each of these child contexts has their own Configuration that will fetch their properties using a
@PropertySource
annotation.In these configurations files I configure a different
server.port
.Context A will have port 8081 and Context B will have port 8082.
When using 2.3.0 it seems that these properties aren't correctly picked up as I see that both modules try to use port 8080 and I get the error: "Web server failed to start. Port 8080 was already in use.".
When downgrading to 2.2.7 this works as it should be and Context A will use port 8081 and Context B will use port 8082.
This repository contains a project that replicates this problem: https://github.com/stijnvanbever/spring-context-hierarchy
My setup:
Spring Boot version: 2.3.0
JVM: OpenJDK 11.0.6
The text was updated successfully, but these errors were encountered: