Skip to content

Document that @ConditionalOnClass should not be used directly on methods #15578

@snicoll

Description

@snicoll

The condition can't be put in places where the JVM may have loaded the class and look at method definitions.

A typical use case is a @Bean method that returns something and that something may not be on the classpath. Using the condition on the method will be useless as the JVM will load the class before the condition kicks in.

It would be nice to update both the ref guide and the javadoc.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions