@@ -7416,6 +7416,9 @@ jdbc.password=
7416
7416
}
7417
7417
----
7418
7418
7419
+
7420
+
7421
+
7419
7422
[[beans-environment]]
7420
7423
== Environment abstraction
7421
7424
@@ -7437,6 +7440,8 @@ on. The role of the `Environment` object with relation to properties is to provi
7437
7440
user with a convenient service interface for configuring property sources and resolving
7438
7441
properties from them.
7439
7442
7443
+
7444
+
7440
7445
[[beans-definition-profiles]]
7441
7446
=== Bean definition profiles
7442
7447
@@ -7563,6 +7568,18 @@ of creating a custom _composed annotation_. The following example defines a cust
7563
7568
}
7564
7569
----
7565
7570
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
+
7566
7583
`@Profile` can also be declared at the method level to include only one particular bean
7567
7584
of a configuration class:
7568
7585
@@ -7591,20 +7608,19 @@ of a configuration class:
7591
7608
}
7592
7609
----
7593
7610
7594
- [TIP ]
7611
+ [NOTE ]
7595
7612
====
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.
7604
7619
====
7605
7620
7621
+
7606
7622
[[beans-definition-profiles-xml]]
7607
- === XML bean definition profiles
7623
+ ==== XML bean definition profiles
7608
7624
7609
7625
The XML counterpart is the `profile` attribute of the `<beans>` element. Our sample
7610
7626
configuration above can be rewritten in two XML files as follows:
0 commit comments