Skip to content

Commit 0a30071

Browse files
Raina Banerjeewilkinsona
Raina Banerjee
authored andcommitted
Fix bean name by adding sample class with prefix
See gh-34029
1 parent 595ac43 commit 0a30071

File tree

3 files changed

+12
-2
lines changed
  • spring-boot-project/spring-boot-docs/src
    • docs/asciidoc/features
    • main
      • java/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes
      • kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes

3 files changed

+12
-2
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ In these cases, specify the list of types to process using the `@EnableConfigura
756756
This can be done on any `@Configuration` class, as shown in the following example:
757757

758758
include::code:MyConfiguration[]
759+
include::code:SomeProperties[]
759760

760761
To use configuration property scanning, add the `@ConfigurationPropertiesScan` annotation to your application.
761762
Typically, it is added to the main application class that is annotated with `@SpringBootApplication` but it can be added to any `@Configuration` class.
@@ -769,7 +770,7 @@ include::code:MyApplication[]
769770
When the `@ConfigurationProperties` bean is registered using configuration property scanning or through `@EnableConfigurationProperties`, the bean has a conventional name: `<prefix>-<fqn>`, where `<prefix>` is the environment key prefix specified in the `@ConfigurationProperties` annotation and `<fqn>` is the fully qualified name of the bean.
770771
If the annotation does not provide any prefix, only the fully qualified name of the bean is used.
771772
772-
The bean name in the example above is `com.example.app-com.example.app.SomeProperties`.
773+
The bean name in the example above is `some.properties-com.example.app.SomeProperties`.
773774
====
774775

775776
We recommend that `@ConfigurationProperties` only deal with the environment and, in particular, does not inject other beans from the context.

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/SomeProperties.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.enablingannotatedtypes;
1818

19-
class SomeProperties {
19+
import org.springframework.boot.context.properties.ConfigurationProperties;
20+
21+
@ConfigurationProperties("some.properties")
22+
public class SomeProperties {
2023

2124
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.enablingannotatedtypes
2+
3+
import org.springframework.boot.context.properties.ConfigurationProperties
4+
5+
@ConfigurationProperties("some.properties")
6+
class SomeProperties

0 commit comments

Comments
 (0)