Skip to content

Commit bdf0ef1

Browse files
committed
Correct docs for use of static with @ConfigurationPropertiesBinding
Closes gh-45621
1 parent 6b8ab75 commit bdf0ef1

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/features/external-config.adoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,11 +1141,10 @@ If you need custom type conversion, you can provide a javadoc:org.springframewor
11411141
====
11421142
Beans used for property conversion are requested very early during the application lifecycle so make sure to limit the dependencies that your javadoc:org.springframework.core.convert.ConversionService[] is using.
11431143
Typically, any dependency that you require may not be fully initialized at creation time.
1144-
1145-
You should also declare any javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans using `static` methods to avoid "`bean is not eligible for getting processed by all BeanPostProcessors`" warnings.
11461144
====
11471145

11481146
TIP: You may want to rename your custom javadoc:org.springframework.core.convert.ConversionService[] if it is not required for configuration keys coercion and only rely on custom converters qualified with javadoc:org.springframework.boot.context.properties.ConfigurationPropertiesBinding[format=annotation].
1147+
When qualifying a `@Bean` method with `@ConfigurationPropertiesBinding`, the method should be `static` to avoid "`bean is not eligible for getting processed by all BeanPostProcessors`" warnings.
11491148

11501149

11511150

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationProperties.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@
3737
* <p>
3838
* Note that contrary to {@code @Value}, SpEL expressions are not evaluated since property
3939
* values are externalized.
40-
* <p>
41-
* Static methods should be used when declaring {@code @ConfigurationProperties} beans to
42-
* ensure that "bean is not eligible for getting processed by all BeanPostProcessors"
43-
* warnings are not produced.
4440
*
4541
* @author Dave Syer
4642
* @since 1.0.0

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBinding.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,10 +23,15 @@
2323
import java.lang.annotation.Target;
2424

2525
import org.springframework.beans.factory.annotation.Qualifier;
26+
import org.springframework.context.annotation.Bean;
2627

2728
/**
2829
* Qualifier for beans that are needed to configure the binding of
2930
* {@link ConfigurationProperties @ConfigurationProperties} (e.g. Converters).
31+
* <p>
32+
* {@link Bean @Bean} methods that declare a {@code @ConfigurationPropertiesBinding} bean
33+
* should be {@code static} to ensure that "bean is not eligible for getting processed by
34+
* all BeanPostProcessors" warnings are not produced.
3035
*
3136
* @author Dave Syer
3237
* @since 1.3.0

0 commit comments

Comments
 (0)