Skip to content

Fix BeanPostProcessorChecker warnings with Spring Cloud 2025.0.0#754

Merged
huayanYu merged 2 commits intomasterfrom
copilot/fix-beanpostprocessor-checker-warnings
Dec 19, 2025
Merged

Fix BeanPostProcessorChecker warnings with Spring Cloud 2025.0.0#754
huayanYu merged 2 commits intomasterfrom
copilot/fix-beanpostprocessor-checker-warnings

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 19, 2025

When using Spring Cloud 2025.0.0, startup produces four BeanPostProcessorChecker warnings about beans not eligible for processing by all BeanPostProcessors. This occurs because DynamicDataSourceProperties is registered via a static bean method, which triggers early instantiation before Spring Cloud's configurationPropertiesBeans BeanPostProcessor is fully initialized.

Changes

  • Replace static dynamicDataSourceProperties() bean method with @EnableConfigurationProperties(DynamicDataSourceProperties.class) annotation
  • Applied to all three starter modules:
    • dynamic-datasource-spring-boot-starter
    • dynamic-datasource-spring-boot3-starter
    • dynamic-datasource-spring-boot4-starter

Before

@Configuration(proxyBeanMethods = false)
public class DynamicDataSourceAopConfiguration {
    @Bean
    public static DynamicDataSourceProperties dynamicDataSourceProperties() {
        return new DynamicDataSourceProperties();
    }
}

After

@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(DynamicDataSourceProperties.class)
public class DynamicDataSourceAopConfiguration {
    // Bean method removed - properties registered via annotation
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • maven.aliyun.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant (dns block)
    • Triggering command: /usr/lib/jvm/temurin-8-jdk-amd64/bin/java /usr/lib/jvm/temurin-8-jdk-amd64/bin/java -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/agents/gradle-instrumentation-agent-8.13.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.13 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>使用Spring cloud 2025.0.0,启动会报四个BeanPostProcessorChecker的警告</issue_title>
<issue_description>```
2025-07-21T18:46:41.413+08:00 WARN 12804 --- [test] [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration' of type [org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected/applied to a currently created BeanPostProcessor [configurationPropertiesBeans]? Check the corresponding BeanPostProcessor declaration and its dependencies/advisors. If this bean does not have to be post-processed, declare it with ROLE_INFRASTRUCTURE.
2025-07-21T18:46:41.413+08:00 WARN 12804 --- [test] [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected/applied to a currently created BeanPostProcessor [configurationPropertiesBeans]? Check the corresponding BeanPostProcessor declaration and its dependencies/advisors. If this bean does not have to be post-processed, declare it with ROLE_INFRASTRUCTURE.
2025-07-21T18:46:41.415+08:00 WARN 12804 --- [test] [ main] trationDelegate$BeanPostProcessorChecker : Bean 'loadBalancerClientsDefaultsMappingsProvider' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration$$Lambda/0x000001dd2049a888] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected/applied to a currently created BeanPostProcessor [configurationPropertiesBeans]? Check the corresponding BeanPostProcessor declaration and its dependencies/advisors. If this bean does not have to be post-processed, declare it with ROLE_INFRASTRUCTURE.
2025-07-21T18:46:41.415+08:00 WARN 12804 --- [test] [ main] trationDelegate$BeanPostProcessorChecker : Bean 'defaultsBindHandlerAdvisor' of type [org.springframework.cloud.commons.config.DefaultsBindHandlerAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected/applied to a currently created BeanPostProcessor [configurationPropertiesBeans]? Check the corresponding BeanPostProcessor declaration and its dependencies/advisors. If this bean does not have to be post-processed, declare it with ROLE_INFRASTRUCTURE.



下面是我的pom文件:


4.0.0

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.5.0</version>
    <relativePath/>
</parent>

<groupId>com.test</groupId>
<artifactId>test-mp</artifactId>
<version>1.0-SNAPSHOT</version>



<properties>
    <maven.compiler.source>21</maven.compiler.source>
    <maven.compiler.target>21</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>2025.0.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-alibaba-dependencies</artifactId>
            <version>2023.0.3.3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>dynamic-datasource-spring-boot3-starter</artifactId>
        <version>4.3.1</version>
    </dependency>
    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
        <scope>runtime</scope>...

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Replace static DynamicDataSourceProperties bean method with
@EnableConfigurationProperties annotation to properly integrate
with Spring Cloud's configurationPropertiesBeans BeanPostProcessor.

Co-authored-by: huayanYu <16700837+huayanYu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix warnings from BeanPostProcessorChecker in Spring Cloud Fix BeanPostProcessorChecker warnings with Spring Cloud 2025.0.0 Dec 19, 2025
Copilot AI requested a review from huayanYu December 19, 2025 08:57
@huayanYu huayanYu marked this pull request as ready for review December 19, 2025 11:00
Copilot AI review requested due to automatic review settings December 19, 2025 11:00
@huayanYu huayanYu merged commit 9aea8ed into master Dec 19, 2025
7 of 8 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes BeanPostProcessorChecker warnings that occur when using Spring Cloud 2025.0.0 with the dynamic-datasource library. The warnings were caused by the static bean method for DynamicDataSourceProperties triggering early instantiation before Spring Cloud's configurationPropertiesBeans BeanPostProcessor was fully initialized.

Key Changes

  • Replaced static dynamicDataSourceProperties() bean method with @EnableConfigurationProperties(DynamicDataSourceProperties.class) annotation
  • Applied consistently across all three Spring Boot starter modules
  • Maintains the same functionality while resolving the bean initialization order issue

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
dynamic-datasource-spring-boot-starter/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DynamicDataSourceAopConfiguration.java Adds @EnableConfigurationProperties annotation and removes static bean method for Spring Boot 2.x starter
dynamic-datasource-spring-boot3-starter/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DynamicDataSourceAopConfiguration.java Adds @EnableConfigurationProperties annotation and removes static bean method for Spring Boot 3.x starter
dynamic-datasource-spring-boot4-starter/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DynamicDataSourceAopConfiguration.java Adds @EnableConfigurationProperties annotation and removes static bean method for Spring Boot 4.x starter

The changes look good overall. The approach is correct and follows Spring Boot best practices for registering @ConfigurationProperties beans. The fix properly addresses the root cause of the BeanPostProcessorChecker warnings by ensuring that DynamicDataSourceProperties is registered through the standard @EnableConfigurationProperties mechanism rather than through a static bean method that causes early initialization.

The implementation is consistent across all three starter modules, and the constructor injection pattern in DynamicDataSourceAopConfiguration will work seamlessly with the new annotation-based registration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

使用Spring cloud 2025.0.0,启动会报四个BeanPostProcessorChecker的警告

3 participants