Merge pull request #34029 from Anubhav-2000
* gh-34029: Polish "Fix bean name by adding sample class with prefix" Fix bean name by adding sample class with prefix Closes gh-34029
This commit is contained in:
commit
d1fe1ae7a8
|
|
@ -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:
|
This can be done on any `@Configuration` class, as shown in the following example:
|
||||||
|
|
||||||
include::code:MyConfiguration[]
|
include::code:MyConfiguration[]
|
||||||
|
include::code:SomeProperties[]
|
||||||
|
|
||||||
To use configuration property scanning, add the `@ConfigurationPropertiesScan` annotation to your application.
|
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.
|
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: `<prefix>-<fqn>`, where `<prefix>` is the environment key prefix specified in the `@ConfigurationProperties` annotation and `<fqn>` is the fully qualified name of the bean.
|
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.
|
||||||
If the annotation does not provide any prefix, only the fully qualified name of the bean is used.
|
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`.
|
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.
|
We recommend that `@ConfigurationProperties` only deal with the environment and, in particular, does not inject other beans from the context.
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.enablingannotatedtypes;
|
package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.enablingannotatedtypes;
|
||||||
|
|
||||||
class SomeProperties {
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
@ConfigurationProperties("some.properties")
|
||||||
|
public class SomeProperties {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
Loading…
Reference in New Issue