-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using the @ConditionalOnClass annotation in the method results in java.lang.ArrayStoreException #17282
Comments
Unfortunately, this is how the JVM works and there’s nothing Spring Boot or Framework can do about it. That is why the javadoc for |
@Bean
@ConditionalOnClass(MongoTemplate.class)
public MongoDataLayerAdapter mongoDataLayerAdapter() {
return new MongoDataLayerAdapter();
} When I use this
Now I modified it to use name injection. And using the fully qualified package name of the class can bypass Java's reflect problem.
now. it works. 😃 |
Using the @ConditionalOnClass annotation in the method results in "java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy",
The main reason is to traverse all methods of the class in org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor, call the method object to get all annotations on the method, but throw an exception when the conditional class does not exist
See my code examples and exception information
The text was updated successfully, but these errors were encountered: