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

Comment From: wilkinsona

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.

Comment From: stijnvanbever

I see. Thanks for the explanation.

Is there anything I can do to contribute to a fix?

Comment From: wilkinsona

Thanks very much for the offer, @stijnvanbever. We're not yet sure on how to fix it. We'll hopefully figure that out later today.