Skip to content

Enable proper override of binder beans with user-defined configurations in a multi-binder scenario #3123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,10 @@ public void onApplicationEvent(ApplicationEvent event) {
}
}

// Register the sources classes to the specific binder context after configuring the environment property sources
List<Class> sourceClasses = new ArrayList<>(Arrays.asList(binderType.getConfigurationClasses()));
// Modified registration: first user classes (spring.main.sources) and then binder classes
List<Class> sourceClasses = new ArrayList<>();

// First register user classes if defined in spring.main.sources
if (binderProperties.containsKey("spring.main.sources")) {
String sources = (String) binderProperties.get("spring.main.sources");
if (StringUtils.hasText(sources)) {
Expand All @@ -525,6 +527,10 @@ public void onApplicationEvent(ApplicationEvent event) {
});
}
}

// Then add binder configuration classes
sourceClasses.addAll(Arrays.asList(binderType.getConfigurationClasses()));

binderProducingContext.register(sourceClasses.toArray(new Class[] {}));

if (refresh) {
Expand Down