Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
ab7bec11
Commit
ab7bec11
authored
Oct 14, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update clarify of bean conditions
See gh-4104
parent
ff0daa8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
14 deletions
+9
-14
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+9
-14
No files found.
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
ab7bec11
...
@@ -3880,20 +3880,15 @@ attribute to specify beans by type, or `name` to specify beans by name. The `sea
...
@@ -3880,20 +3880,15 @@ attribute to specify beans by type, or `name` to specify beans by name. The `sea
attribute allows you to limit the `ApplicationContext` hierarchy that should be considered
attribute allows you to limit the `ApplicationContext` hierarchy that should be considered
when searching for beans.
when searching for beans.
Conditions are evaluated after all configuration classes have been processed. This clearly
TIP: You need to be very careful about the order that bean definitions are added as these
means that you can't use it to make a whole configuration class conditional on the presence
conditions are evaluated based on what has been processed so far. For this reason,
(or absence) of another bean. You can, however, use it when you have to share that
we recommend only using `@ConditionalOnBean` and `@ConditionalOnMissingBean` annotations
condition with all the beans of that configuration class.
on auto-configuration classes (since these are guaranteed to load after any user-define
beans definitions have been added).
[NOTE]
====
NOTE: `@ConditionalOnBean` and `@ConditionalOnMissingBean` do not prevent `@Configuration`
You also need to be very careful about ordering as the condition will be evaluated based on
classes from being created. Using these conditions at the class level is equivalent to
the bean definitions that have been processed so far. Auto-configured `@Configuration` is
marking each contained `@Bean` method with the annotation.
always parsed last (after any user defined beans) so it is recommended to restrict the use
of that condition on auto-configuration classes only. However, if you are sure that the bean
targeted at the condition won't be created by auto-configuration, then you could use it on a
normal configuration class with appropriate ordering.
====
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment