Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
0a55e3e7
Commit
0a55e3e7
authored
Apr 10, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Clarify edge case docs on ConditionalOnClass"
Closes gh-8185
parent
08f82192
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
18 deletions
+17
-18
ConditionalOnClass.java
...work/boot/autoconfigure/condition/ConditionalOnClass.java
+5
-8
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+12
-10
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnClass.java
View file @
0a55e3e7
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
7
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -36,14 +36,11 @@ import org.springframework.context.annotation.Conditional;
...
@@ -36,14 +36,11 @@ import org.springframework.context.annotation.Conditional;
public
@interface
ConditionalOnClass
{
public
@interface
ConditionalOnClass
{
/**
/**
* <p>
* The classes that must be present. Since this annotation is parsed by loading class
* The classes that must be present. Since this annotation parsed by loading class
* bytecode, it is safe to specify classes here that may ultimately not be on the
* bytecode it is safe to specify classes here that may ultimately not be on the
* classpath, only if this annotation is directly on the affected component and
* classpath, only if this annotation is directly on the affected component and
* <b>not</b> if this annotation is used as a composed, meta-annotation. If this
* <b>not</b> if this annotation is used as a composed, meta-annotation. In order to
* is used as a meta annotation and the given class is not available at runtime
* use this annotation as a meta-annotation, only use the {@link #name} attribute.
* then this {@link @Conditional} will effectively be ignored. In order to use
* this annotation as a meta-annotation, only use the {@link #name} attribute.
* @return the classes that must be present
* @return the classes that must be present
*/
*/
Class
<?>[]
value
()
default
{};
Class
<?>[]
value
()
default
{};
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
0a55e3e7
...
@@ -5839,16 +5839,18 @@ code by annotating `@Configuration` classes or individual `@Bean` methods.
...
@@ -5839,16 +5839,18 @@ code by annotating `@Configuration` classes or individual `@Bean` methods.
[[boot-features-class-conditions]]
[[boot-features-class-conditions]]
==== Class conditions
==== Class conditions
The `@ConditionalOnClass` and `@ConditionalOnMissingClass` annotations allows
The `@ConditionalOnClass` and `@ConditionalOnMissingClass` annotations allows
configuration to be included based on the presence or absence of specific classes.
configuration to be included based on the presence or absence of specific classes. Due to
If you are using the `@ConditionalOnClass` annotation directly on the class you are conditionally
the fact that annotation metadata is parsed using http://asm.ow2.org/[ASM] you can
registering, you can actually use the `value` attribute to refer to the real class,
actually use the `value` attribute to refer to the real class, even though that class
even though that class might not actually appear on the running application classpath.
might not actually appear on the running application classpath. You can also use the
This is due to the fact that annotation metadata directly on a class is parsed
`name` attribute if you prefer to specify the class name using a `String` value.
using http://asm.ow2.org/[ASM]. You can also use the `name` attribute if you prefer to
specify the class name using a `String` value, which is required if you are using
[TIP]
`@ConditionalOnClass` or `@ConditionalOnMissingClass` as apart of a meta-annotation to
====
compose your own composed annotations or in an `@Bean` method as neither of these cases
If you are using `@ConditionalOnClass` or `@ConditionalOnMissingClass` as apart of a
are handled by ASM.
meta-annotation to compose your own composed annotations you must use `name` as referring
to the class in such a case is not handled.
====
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment