啟動spring-boot出現Error creating bean with name ‘configurationPropertiesBeans‘ defined in class的報錯


整合注冊中心Eureka,啟動provider_service服務的時候出現了如下的報錯:(后面發現是由於provider_service,eureka_server使用的spring-boot版本不一致導致報錯)

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans]: Factory method 'configurationPropertiesBeans' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:484) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1179) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:571) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.1.jar:5.3.1]
 

后面仔細查看了pom.xml之后發現

provider_service的pom.xml里面的spring-boot是2.4版本的

  1.  
    <groupId>org.springframework.boot</groupId>
  2.  
    <artifactId>spring-boot-starter-parent</artifactId>
  3.  
    <version>2.4.0</version>

而注冊中心Eureka(eureka_server)pom.xml的spring-boot的版本為:

  1.  
    <groupId>org.springframework.boot</groupId>
  2.  
    <artifactId>spring-boot-starter-parent</artifactId>
  3.  
    <version>2.2.11.RELEASE</version>
  4.  
    <relativePath/>

后面將provider_service的pom.xml里面的spring-boot版本修改和eureka_server一致,provider_service服務就能正常開啟了。

總結:整合注冊中心Eureka的時候,各個服務使用的spring-boot版本最好保持一致,不然可能會出現未知錯誤。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM