Skip to content

Commit ac98d2a

Browse files
committed
Merge pull request #8185 from phillipuniverse:master
* pr/8185: Polish "Clarify edge case docs on ConditionalOnClass" Clarify edge case docs on ConditionalOnClass
2 parents a8860ba + 0a55e3e commit ac98d2a

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnClass.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,9 +36,11 @@
3636
public @interface ConditionalOnClass {
3737

3838
/**
39-
* The classes that must be present. Since this annotation parsed by loading class
40-
* bytecode it is safe to specify classes here that may ultimately not be on the
41-
* classpath.
39+
* The classes that must be present. Since this annotation is parsed by loading class
40+
* bytecode, it is safe to specify classes here that may ultimately not be on the
41+
* classpath, only if this annotation is directly on the affected component and
42+
* <b>not</b> if this annotation is used as a composed, meta-annotation. In order to
43+
* use this annotation as a meta-annotation, only use the {@link #name} attribute.
4244
* @return the classes that must be present
4345
*/
4446
Class<?>[] value() default {};

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5845,6 +5845,13 @@ actually use the `value` attribute to refer to the real class, even though that
58455845
might not actually appear on the running application classpath. You can also use the
58465846
`name` attribute if you prefer to specify the class name using a `String` value.
58475847

5848+
[TIP]
5849+
====
5850+
If you are using `@ConditionalOnClass` or `@ConditionalOnMissingClass` as apart of a
5851+
meta-annotation to compose your own composed annotations you must use `name` as referring
5852+
to the class in such a case is not handled.
5853+
====
5854+
58485855

58495856

58505857
[[boot-features-bean-conditions]]

0 commit comments

Comments
 (0)