0

Today I upgraded my Spring Cloud to version 2020.0.3 and Spring Boot version to 2.4.9. When I run the app shows error like this:

Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata
at java.net.URLClassLoader.findClass(URLClassLoader.java:605) ~[?:?]
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:1183) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:1098) ~[?:?]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151) ~[dolphin-gateway-1.0.0-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:1081) ~[?:?]
at java.lang.Class.getDeclaredMethodsImpl(Native Method) ~[?:?]
at java.lang.Class.getDeclaredMethods(Class.java:1146) ~[?:?]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ~[spring-core-5.3.9.jar!/:5.3.9]
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321) ~[spring-core-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.buildLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:232) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.findLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:210) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(InitDestroyAnnotationBeanPostProcessor.java:149) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:294) ~[spring-context-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1098) ~[spring-beans-5.3.9.jar!/:5.3.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576) ~[spring-beans-5.3.9.jar!/:5.3.9]
... 41 more

I've searched the internet and this told me this problem is caused by a version incompatibility. The version is compatible right now, I read the official document, why does it still show this error? What should I do to fix it? I found the org.springframework.boot:spring-boot-starter-data-redis using org.springframework:spring-beans:5.3.9, is there possible to fix?

$ ./script/dependencies.sh                                                                                                                                                           ‹ruby-2.7.2›
+ ./gradlew :dolphin-gateway:dependencies --configuration runtimeClasspath
+ grep -v '(*)'
+ grep -C 10 spring-beans
|    |    +--- org.apache.commons:commons-collections4:4.4
|    |    +--- org.apache.commons:commons-lang3:3.9
|    |    +--- org.springframework.boot:spring-boot-starter-parent:2.4.9
|    |    +--- org.springframework.boot:spring-boot-starter-data-redis -> 2.4.9
|    |    |    \--- org.springframework.boot:spring-boot-starter:2.4.9
|    |    |         +--- org.springframework.boot:spring-boot:2.4.9
|    |    |         |    +--- org.springframework:spring-core:5.3.9
|    |    |         |    |    \--- org.springframework:spring-jcl:5.3.9
|    |    |         |    \--- org.springframework:spring-context:5.3.9
|    |    |         |         +--- org.springframework:spring-aop:5.3.9
|    |    |         |         |    +--- org.springframework:spring-beans:5.3.9
|    |    |         |         \--- org.springframework:spring-expression:5.3.9
|    |    |         +--- org.springframework.boot:spring-boot-autoconfigure:2.4.9
|    |    |         +--- org.springframework.boot:spring-boot-starter-logging:2.4.9
|    |    |         |    \--- org.slf4j:jul-to-slf4j:1.7.32
|    |    |         |         \--- org.slf4j:slf4j-api:1.7.32
|    |    |         +--- jakarta.annotation:jakarta.annotation-api:1.3.5
|    |    |         \--- org.yaml:snakeyaml:1.27
|    |    +--- org.springframework.data:spring-data-redis:2.5.0
|    |    |    +--- org.springframework.data:spring-data-keyvalue:2.5.0 -> 2.4.11
|    |    |    |    +--- org.springframework.data:spring-data-commons:2.4.11
(base)
Dolphin
  • 29,069
  • 61
  • 260
  • 539
  • Does this answer your question? [How do I resolve ClassNotFoundException?](https://stackoverflow.com/questions/17408769/how-do-i-resolve-classnotfoundexception) – TBA Nov 21 '21 at 11:24
  • No, it did not answer my question.@TBA – Dolphin Nov 21 '21 at 11:25
  • 2
    It sounds like your dependency versions are not what you expect them to be. `ConfigurationBeanFactoryMetadata` was removed in Spring Boot 2.4.0-M4: https://github.com/spring-projects/spring-boot/commit/35d41e4ae266c257596f54395b5b403f1ee705ab#diff-c5adb3edfdcff4635dcd621bbc1b6d9b7770d87595257c5bae24206961f1b8c5. Spring Cloud 2020.0.x does not depend upon it so it sounds like you may have some dependencies from Spring Cloud Hoxton on the classpath too. – Andy Wilkinson Nov 21 '21 at 18:06
  • I searched in Intellij Idea and did not found this class in any dependencies contains class `ConfigurationBeanFactoryMetadata`. @AndyWilkinson – Dolphin Nov 22 '21 at 02:56
  • 1
    It has been removed so I would not expect your IDE to be able to find it. – Andy Wilkinson Nov 22 '21 at 11:36

1 Answers1

-1

seems Spring Boot remove the class ConfigurationBeanFactoryMetadata from version 2.4.1, I downgrade the version to 2.4.0 avoid the problem.

Dolphin
  • 29,069
  • 61
  • 260
  • 539