@@ -7416,6 +7416,9 @@ jdbc.password=
74167416 }
74177417----
74187418
7419+
7420+
7421+
74197422[[beans-environment]]
74207423== Environment abstraction
74217424
@@ -7437,6 +7440,8 @@ on. The role of the `Environment` object with relation to properties is to provi
74377440user with a convenient service interface for configuring property sources and resolving
74387441properties from them.
74397442
7443+
7444+
74407445[[beans-definition-profiles]]
74417446=== Bean definition profiles
74427447
@@ -7563,6 +7568,18 @@ of creating a custom _composed annotation_. The following example defines a cust
75637568 }
75647569----
75657570
7571+ [TIP]
7572+ ====
7573+ If a `@Configuration` class is marked with `@Profile`, all of the `@Bean` methods and
7574+ `@Import` annotations associated with that class will be bypassed unless one or more of
7575+ the specified profiles are active. If a `@Component` or `@Configuration` class is marked
7576+ with `@Profile({"p1", "p2"})`, that class will not be registered/processed unless
7577+ profiles 'p1' and/or 'p2' have been activated. If a given profile is prefixed with the
7578+ NOT operator (`!`), the annotated element will be registered if the profile is **not**
7579+ active. For example, given `@Profile({"p1", "!p2"})`, registration will occur if profile
7580+ 'p1' is active or if profile 'p2' is not active.
7581+ ====
7582+
75667583`@Profile` can also be declared at the method level to include only one particular bean
75677584of a configuration class:
75687585
@@ -7591,20 +7608,19 @@ of a configuration class:
75917608 }
75927609----
75937610
7594- [TIP ]
7611+ [NOTE ]
75957612====
7596- If a `@Configuration` class is marked with `@Profile`, all of the `@Bean` methods and
7597- `@Import` annotations associated with that class will be bypassed unless one or more of
7598- the specified profiles are active. If a `@Component` or `@Configuration` class is marked
7599- with `@Profile({"p1", "p2"})`, that class will not be registered/processed unless
7600- profiles 'p1' and/or 'p2' have been activated. If a given profile is prefixed with the
7601- NOT operator (`!`), the annotated element will be registered if the profile is **not**
7602- active. For example, given `@Profile({"p1", "!p2"})`, registration will occur if profile
7603- 'p1' is active or if profile 'p2' is not active.
7613+ With `@Profile` on `@Bean` methods, a special scenario may apply: In the case of
7614+ overloaded `@Bean` methods, all `@Profile` declarations from all applicable factory
7615+ methods for the same bean will be merged; as a consequence, they all need to match
7616+ for the bean to become registered. `@Profile` can therefore not be used to select
7617+ a particular overloaded method over another; resolution between overloaded factory
7618+ methods only follows Spring's constructor resolution algorithm.
76047619====
76057620
7621+
76067622[[beans-definition-profiles-xml]]
7607- === XML bean definition profiles
7623+ ==== XML bean definition profiles
76087624
76097625The XML counterpart is the `profile` attribute of the `<beans>` element. Our sample
76107626configuration above can be rewritten in two XML files as follows:
0 commit comments