Skip to content

Configuring server.* properties in a child context has no effect in Spring Boot 2.3 #21789

@stijnvanbever

Description

@stijnvanbever

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

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