@@ -5233,9 +5233,9 @@ method parameters, as shown in the following example:
52335233----
52345234 public class MovieRecommender {
52355235
5236- private MovieCatalog movieCatalog;
5236+ private final MovieCatalog movieCatalog;
52375237
5238- private CustomerPreferenceDao customerPreferenceDao;
5238+ private final CustomerPreferenceDao customerPreferenceDao;
52395239
52405240 @Autowired
52415241 public void prepare(@Qualifier("main") MovieCatalog movieCatalog,
@@ -5492,7 +5492,6 @@ the simple annotation, as the following example shows:
54925492 @Retention(RetentionPolicy.RUNTIME)
54935493 @Qualifier
54945494 public @interface Offline {
5495-
54965495 }
54975496----
54985497[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -8094,7 +8093,7 @@ class AppConfig {
80948093By default, beans defined with Java configuration that have a public `close` or `shutdown`
80958094method are automatically enlisted with a destruction callback. If you have a public
80968095`close` or `shutdown` method and you do not wish for it to be called when the container
8097- shuts down, you can add `@Bean(destroyMethod= "")` to your bean definition to disable the
8096+ shuts down, you can add `@Bean(destroyMethod = "")` to your bean definition to disable the
80988097default `(inferred)` mode.
80998098
81008099You may want to do that by default for a resource that you acquire with JNDI, as its
@@ -8107,7 +8106,7 @@ The following example shows how to prevent an automatic destruction callback for
81078106[source,java,indent=0,subs="verbatim,quotes",role="primary"]
81088107.Java
81098108----
8110- @Bean(destroyMethod= "")
8109+ @Bean(destroyMethod = "")
81118110 public DataSource dataSource() throws NamingException {
81128111 return (DataSource) jndiTemplate.lookup("MyDS");
81138112 }
@@ -9451,7 +9450,7 @@ now looks like the following listing:
94519450[source,java,indent=0,subs="verbatim,quotes",role="primary"]
94529451.Java
94539452----
9454- @Bean(destroyMethod= "")
9453+ @Bean(destroyMethod = "")
94559454 public DataSource dataSource() throws Exception {
94569455 Context ctx = new InitialContext();
94579456 return (DataSource) ctx.lookup("java:comp/env/jdbc/datasource");
@@ -9532,27 +9531,30 @@ can rewrite the `dataSource` configuration as follows:
95329531 @Profile("production")
95339532 public class JndiDataConfig {
95349533
9535- @Bean(destroyMethod= "")
9534+ @Bean(destroyMethod = "") // <1>
95369535 public DataSource dataSource() throws Exception {
95379536 Context ctx = new InitialContext();
95389537 return (DataSource) ctx.lookup("java:comp/env/jdbc/datasource");
95399538 }
95409539 }
95419540----
9541+ <1> `@Bean(destroyMethod = "")` disables default destroy method inference.
9542+
95429543[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
95439544.Kotlin
95449545----
95459546 @Configuration
95469547 @Profile("production")
95479548 class JndiDataConfig {
95489549
9549- @Bean(destroyMethod = "")
9550+ @Bean(destroyMethod = "") // <1>
95509551 fun dataSource(): DataSource {
95519552 val ctx = InitialContext()
95529553 return ctx.lookup("java:comp/env/jdbc/datasource") as DataSource
95539554 }
95549555 }
95559556----
9557+ <1> `@Bean(destroyMethod = "")` disables default destroy method inference.
95569558
95579559NOTE: As mentioned earlier, with `@Bean` methods, you typically choose to use programmatic
95589560JNDI lookups, by using either Spring's `JndiTemplate`/`JndiLocatorDelegate` helpers or the
@@ -9564,9 +9566,9 @@ profile expression. A profile expression allows for more complicated profile log
95649566expressed (for example, `production & us-east`). The following operators are supported in
95659567profile expressions:
95669568
9567- * `!`: A logical "`not`" of the profile
9568- * `&`: A logical "`and`" of the profiles
9569- * `|`: A logical "`or`" of the profiles
9569+ * `!`: A logical `NOT` of the profile
9570+ * `&`: A logical `AND` of the profiles
9571+ * `|`: A logical `OR` of the profiles
95709572
95719573NOTE: You cannot mix the `&` and `|` operators without using parentheses. For example,
95729574`production & us-east | eu-central` is not a valid expression. It must be expressed as
@@ -9829,7 +9831,7 @@ activates multiple profiles:
98299831Declaratively, `spring.profiles.active` may accept a comma-separated list of profile names,
98309832as the following example shows:
98319833
9832- [literal,subs="verbatim,quotes"]
9834+ [literal,indent=0, subs="verbatim,quotes"]
98339835----
98349836 -Dspring.profiles.active="profile1,profile2"
98359837----
@@ -10225,13 +10227,13 @@ handled in the JDK-standard way of resolving messages through `ResourceBundle` o
1022510227purposes of the example, assume the contents of two of the above resource bundle files
1022610228are as follows:
1022710229
10228- [literal ,subs="verbatim,quotes"]
10230+ [source,properties,indent=0 ,subs="verbatim,quotes"]
1022910231----
1023010232 # in format.properties
1023110233 message=Alligators rock!
1023210234----
1023310235
10234- [literal ,subs="verbatim,quotes"]
10236+ [source,properties,indent=0 ,subs="verbatim,quotes"]
1023510237----
1023610238 # in exceptions.properties
1023710239 argument.required=The {0} argument is required.
0 commit comments