Skip to content

Commit

Permalink
Merge branch '2.6.x' into 2.7.x
Browse files Browse the repository at this point in the history
Closes gh-32167
  • Loading branch information
philwebb committed Aug 25, 2022
2 parents 257e236 + 24c2daa commit 10ded39
Showing 1 changed file with 27 additions and 5 deletions.
Expand Up @@ -28,11 +28,33 @@
* {@link Conditional @Conditional} that only matches when the specified classes are on
* the classpath.
* <p>
* A {@link #value()} can be safely specified on {@code @Configuration} classes as the
* annotation metadata is parsed by using ASM before the class is loaded. Extra care is
* required when placed on {@code @Bean} methods, consider isolating the condition in a
* separate {@code Configuration} class, in particular if the return type of the method
* matches the {@link #value target of the condition}.
* A {@code Class} {@link #value() value} can be safely specified on
* {@code @Configuration} classes as the annotation metadata is parsed by using ASM before
* the class is loaded. If a class reference cannot be used then a {@link #name() name}
* {@code String} attribute can be used.
* <p>
* <b>Note:</b> Extra care must be taken when using {@code @ConditionalOnClass} on
* {@code @Bean} methods where typically the return type is the target of the condition.
* Before the condition on the method applies, the JVM will have loaded the class and
* potentially processed method references which will fail if the class is not present. To
* handle this scenario, a separate {@code @Configuration} class should be used to isolate
* the condition. For example: <pre class="code">
* &#064;Configuration(proxyBeanMethods = false)
* public class MyAutoConfiguration {
*
* &#64;Configuration(proxyBeanMethods = false)
* &#64;ConditionalOnClass(SomeService.class)
* public static class SomeServiceConfiguration {
*
* &#64;Bean
* &#64;ConditionalOnMissingBean
* public SomeService someService() {
* return new SomeService();
* }
*
* }
*
* }</pre>
*
* @author Phillip Webb
* @since 1.0.0
Expand Down

0 comments on commit 10ded39

Please sign in to comment.