From 0a3007133bf93368def28051b4eeb3484f9cd079 Mon Sep 17 00:00:00 2001 From: Raina Banerjee Date: Wed, 1 Feb 2023 00:18:41 +0530 Subject: [PATCH 1/2] Fix bean name by adding sample class with prefix See gh-34029 --- .../src/docs/asciidoc/features/external-config.adoc | 3 ++- .../enablingannotatedtypes/SomeProperties.java | 5 ++++- .../enablingannotatedtypes/SomeProperties.kt | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/SomeProperties.kt diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc index ef962bffdb6..a5c3e590178 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc @@ -756,6 +756,7 @@ In these cases, specify the list of types to process using the `@EnableConfigura This can be done on any `@Configuration` class, as shown in the following example: include::code:MyConfiguration[] +include::code:SomeProperties[] To use configuration property scanning, add the `@ConfigurationPropertiesScan` annotation to your application. 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[] When the `@ConfigurationProperties` bean is registered using configuration property scanning or through `@EnableConfigurationProperties`, the bean has a conventional name: `-`, where `` is the environment key prefix specified in the `@ConfigurationProperties` annotation and `` is the fully qualified name of the bean. If the annotation does not provide any prefix, only the fully qualified name of the bean is used. -The bean name in the example above is `com.example.app-com.example.app.SomeProperties`. +The bean name in the example above is `some.properties-com.example.app.SomeProperties`. ==== We recommend that `@ConfigurationProperties` only deal with the environment and, in particular, does not inject other beans from the context. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/SomeProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/SomeProperties.java index 674845bed6e..9e8518eb40f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/SomeProperties.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/SomeProperties.java @@ -16,6 +16,9 @@ package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.enablingannotatedtypes; -class SomeProperties { +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties("some.properties") +public class SomeProperties { } diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/SomeProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/SomeProperties.kt new file mode 100644 index 00000000000..5c209f13cbc --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/SomeProperties.kt @@ -0,0 +1,6 @@ +package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.enablingannotatedtypes + +import org.springframework.boot.context.properties.ConfigurationProperties + +@ConfigurationProperties("some.properties") +class SomeProperties \ No newline at end of file From 710559297e591f06bad1f600f4353c51d5cb1e04 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 14 Feb 2023 21:19:41 +0000 Subject: [PATCH 2/2] Polish "Fix bean name by adding sample class with prefix" See gh-34029 --- .../src/docs/asciidoc/features/external-config.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc index a5c3e590178..9555a07f19b 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/external-config.adoc @@ -770,7 +770,7 @@ include::code:MyApplication[] When the `@ConfigurationProperties` bean is registered using configuration property scanning or through `@EnableConfigurationProperties`, the bean has a conventional name: `-`, where `` is the environment key prefix specified in the `@ConfigurationProperties` annotation and `` is the fully qualified name of the bean. If the annotation does not provide any prefix, only the fully qualified name of the bean is used. -The bean name in the example above is `some.properties-com.example.app.SomeProperties`. +Assuming that it is in the `com.example.app` package, the bean name of the `SomeProperties` example above is `some.properties-com.example.app.SomeProperties`. ==== We recommend that `@ConfigurationProperties` only deal with the environment and, in particular, does not inject other beans from the context.