首页 > 其他分享 >springboot升级到2.6.x和2.7.x 兼容hystrix

springboot升级到2.6.x和2.7.x 兼容hystrix

时间:2024-01-22 14:55:26浏览次数:42  
标签:java springboot hystrix jar springframework MAVEN org 2.7 MavenRepository

一、pom.xml需要引入的依赖

 1  <!-- springboot升级到2.6.7,同样适用于2.7.0,2.7.18等 -->
 2     <parent>
 3         <groupId>org.springframework.boot</groupId>
 4         <artifactId>spring-boot-starter-parent</artifactId>
 5         <version>2.6.7</version>
 6         <relativePath/> <!-- lookup parent from repository -->
 7     </parent>  
 8         
 9       <!-- hystrix需要升级到2.x以上版本 -->
10         <dependency>
11             <groupId>org.springframework.cloud</groupId>
12             <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
13             <version>2.2.10.RELEASE</version>
14        </dependency>
15 
16      <!-- 升级后运行时缺失依赖 -->
17        <dependency>
18         <groupId>org.hdrhistogram</groupId>
19         <artifactId>HdrHistogram</artifactId>
20         <version>2.1.12</version>
21       </dependency>
View Code

二、项目开启熔断器开关

2.1 注解方式

@EnableHystrix

@EnableCircuitBreaker

注:项目启动类中加上以上注解,以上两者取其一即可;

2.2 xml方式

以上注解方式底层就是实例化此类:

 

三、依赖类缺失问题

此时运行项目将报以下错误:

D:\JDK\jdk1.8\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:55698,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -javaagent:C:\Users\mingming.chen\AppData\Local\JetBrains\IntelliJIdea2021.3\captureAgent\debugger-agent.jar -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath "D:\JDK\jdk1.8\jre\lib\charsets.jar;D:\JDK\jdk1.8\jre\lib\deploy.jar;D:\JDK\jdk1.8\jre\lib\ext\access-bridge-64.jar;D:\JDK\jdk1.8\jre\lib\ext\cldrdata.jar;D:\JDK\jdk1.8\jre\lib\ext\dnsns.jar;D:\JDK\jdk1.8\jre\lib\ext\jaccess.jar;D:\JDK\jdk1.8\jre\lib\ext\jfxrt.jar;D:\JDK\jdk1.8\jre\lib\ext\localedata.jar;D:\JDK\jdk1.8\jre\lib\ext\nashorn.jar;D:\JDK\jdk1.8\jre\lib\ext\sunec.jar;D:\JDK\jdk1.8\jre\lib\ext\sunjce_provider.jar;D:\JDK\jdk1.8\jre\lib\ext\sunmscapi.jar;D:\JDK\jdk1.8\jre\lib\ext\sunpkcs11.jar;D:\JDK\jdk1.8\jre\lib\ext\zipfs.jar;D:\JDK\jdk1.8\jre\lib\javaws.jar;D:\JDK\jdk1.8\jre\lib\jce.jar;D:\JDK\jdk1.8\jre\lib\jfr.jar;D:\JDK\jdk1.8\jre\lib\jfxswt.jar;D:\JDK\jdk1.8\jre\lib\jsse.jar;D:\JDK\jdk1.8\jre\lib\management-agent.jar;D:\JDK\jdk1.8\jre\lib\plugin.jar;D:\JDK\jdk1.8\jre\lib\resources.jar;D:\JDK\jdk1.8\jre\lib\rt.jar;D:\LocalReposition\oherproject\testProject\PersonalAssistant\target\classes;D:\MAVEN\MavenRepository\org\springframework\boot\spring-boot-starter\2.6.7\spring-boot-starter-2.6.7.jar;D:\MAVEN\MavenRepository\org\springframework\boot\spring-boot\2.6.7\spring-boot-2.6.7.jar;D:\MAVEN\MavenRepository\org\springframework\spring-context\5.3.19\spring-context-5.3.19.jar;D:\MAVEN\MavenRepository\org\springframework\boot\spring-boot-autoconfigure\2.6.7\spring-boot-autoconfigure-2.6.7.jar;D:\MAVEN\MavenRepository\org\springframework\boot\spring-boot-starter-logging\2.6.7\spring-boot-starter-logging-2.6.7.jar;D:\MAVEN\MavenRepository\ch\qos\logback\logback-classic\1.2.11\logback-classic-1.2.11.jar;D:\MAVEN\MavenRepository\ch\qos\logback\logback-core\1.2.11\logback-core-1.2.11.jar;D:\MAVEN\MavenRepository\org\apache\logging\log4j\log4j-to-slf4j\2.17.2\log4j-to-slf4j-2.17.2.jar;D:\MAVEN\MavenRepository\org\slf4j\jul-to-slf4j\1.7.36\jul-to-slf4j-1.7.36.jar;D:\MAVEN\MavenRepository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;D:\MAVEN\MavenRepository\org\springframework\spring-core\5.3.19\spring-core-5.3.19.jar;D:\MAVEN\MavenRepository\org\springframework\spring-jcl\5.3.19\spring-jcl-5.3.19.jar;D:\MAVEN\MavenRepository\org\yaml\snakeyaml\1.29\snakeyaml-1.29.jar;D:\MAVEN\MavenRepository\org\springframework\boot\spring-boot-starter-test\2.6.7\spring-boot-starter-test-2.6.7.jar;D:\MAVEN\MavenRepository\org\springframework\boot\spring-boot-test\2.6.7\spring-boot-test-2.6.7.jar;D:\MAVEN\MavenRepository\org\springframework\boot\spring-boot-test-autoconfigure\2.6.7\spring-boot-test-autoconfigure-2.6.7.jar;D:\MAVEN\MavenRepository\com\jayway\jsonpath\json-path\2.6.0\json-path-2.6.0.jar;D:\MAVEN\MavenRepository\net\minidev\json-smart\2.4.8\json-smart-2.4.8.jar;D:\MAVEN\MavenRepository\net\minidev\accessors-smart\2.4.8\accessors-smart-2.4.8.jar;D:\MAVEN\MavenRepository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;D:\MAVEN\MavenRepository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;D:\MAVEN\MavenRepository\org\assertj\assertj-core\3.21.0\assertj-core-3.21.0.jar;D:\MAVEN\MavenRepository\org\hamcrest\hamcrest\2.2\hamcrest-2.2.jar;D:\MAVEN\MavenRepository\org\junit\jupiter\junit-jupiter\5.8.2\junit-jupiter-5.8.2.jar;D:\MAVEN\MavenRepository\org\junit\jupiter\junit-jupiter-api\5.8.2\junit-jupiter-api-5.8.2.jar;D:\MAVEN\MavenRepository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;D:\MAVEN\MavenRepository\org\junit\platform\junit-platform-commons\1.8.2\junit-platform-commons-1.8.2.jar;D:\MAVEN\MavenRepository\org\apiguardian\apiguardian-api\1.1.2\apiguardian-api-1.1.2.jar;D:\MAVEN\MavenRepository\org\junit\jupiter\junit-jupiter-params\5.8.2\junit-jupiter-params-5.8.2.jar;D:\MAVEN\MavenRepository\org\junit\jupiter\junit-jupiter-engine\5.8.2\junit-jupiter-engine-5.8.2.jar;D:\MAVEN\MavenRepository\org\junit\platform\junit-platform-engine\1.8.2\junit-platform-engine-1.8.2.jar;D:\MAVEN\MavenRepository\org\mockito\mockito-core\4.0.0\mockito-core-4.0.0.jar;D:\MAVEN\MavenRepository\net\bytebuddy\byte-buddy\1.11.22\byte-buddy-1.11.22.jar;D:\MAVEN\MavenRepository\net\bytebuddy\byte-buddy-agent\1.11.22\byte-buddy-agent-1.11.22.jar;D:\MAVEN\MavenRepository\org\objenesis\objenesis\3.2\objenesis-3.2.jar;D:\MAVEN\MavenRepository\org\mockito\mockito-junit-jupiter\4.0.0\mockito-junit-jupiter-4.0.0.jar;D:\MAVEN\MavenRepository\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;D:\MAVEN\MavenRepository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;D:\MAVEN\MavenRepository\org\springframework\spring-test\5.3.19\spring-test-5.3.19.jar;D:\MAVEN\MavenRepository\org\xmlunit\xmlunit-core\2.8.4\xmlunit-core-2.8.4.jar;D:\MAVEN\MavenRepository\org\springframework\boot\spring-boot-starter-web\2.6.7\spring-boot-starter-web-2.6.7.jar;D:\MAVEN\MavenRepository\org\springframework\boot\spring-boot-starter-json\2.6.7\spring-boot-starter-json-2.6.7.jar;D:\MAVEN\MavenRepository\com\fasterxml\jackson\core\jackson-databind\2.13.2.1\jackson-databind-2.13.2.1.jar;D:\MAVEN\MavenRepository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.13.2\jackson-datatype-jdk8-2.13.2.jar;D:\MAVEN\MavenRepository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.13.2\jackson-datatype-jsr310-2.13.2.jar;D:\MAVEN\MavenRepository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.13.2\jackson-module-parameter-names-2.13.2.jar;D:\MAVEN\MavenRepository\org\springframework\boot\spring-boot-starter-tomcat\2.6.7\spring-boot-starter-tomcat-2.6.7.jar;D:\MAVEN\MavenRepository\org\apache\tomcat\embed\tomcat-embed-core\9.0.62\tomcat-embed-core-9.0.62.jar;D:\MAVEN\MavenRepository\org\apache\tomcat\embed\tomcat-embed-el\9.0.62\tomcat-embed-el-9.0.62.jar;D:\MAVEN\MavenRepository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.62\tomcat-embed-websocket-9.0.62.jar;D:\MAVEN\MavenRepository\org\springframework\spring-web\5.3.19\spring-web-5.3.19.jar;D:\MAVEN\MavenRepository\org\springframework\spring-beans\5.3.19\spring-beans-5.3.19.jar;D:\MAVEN\MavenRepository\org\springframework\spring-webmvc\5.3.19\spring-webmvc-5.3.19.jar;D:\MAVEN\MavenRepository\org\springframework\spring-aop\5.3.19\spring-aop-5.3.19.jar;D:\MAVEN\MavenRepository\org\springframework\spring-expression\5.3.19\spring-expression-5.3.19.jar;D:\MAVEN\MavenRepository\org\apache\mahout\mahout-math\0.13.0\mahout-math-0.13.0.jar;D:\MAVEN\MavenRepository\org\apache\commons\commons-math3\3.2\commons-math3-3.2.jar;D:\MAVEN\MavenRepository\com\google\guava\guava\14.0.1\guava-14.0.1.jar;D:\MAVEN\MavenRepository\it\unimi\dsi\fastutil\7.0.12\fastutil-7.0.12.jar;D:\MAVEN\MavenRepository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;D:\MAVEN\MavenRepository\com\tdunning\t-digest\3.1\t-digest-3.1.jar;D:\MAVEN\MavenRepository\org\tribuo\tribuo-clustering-kmeans\4.3.1\tribuo-clustering-kmeans-4.3.1.jar;D:\MAVEN\MavenRepository\org\tribuo\tribuo-core\4.3.1\tribuo-core-4.3.1.jar;D:\MAVEN\MavenRepository\org\tribuo\tribuo-util-onnx\4.3.1\tribuo-util-onnx-4.3.1.jar;D:\MAVEN\MavenRepository\com\oracle\labs\olcut\olcut-config-protobuf\5.2.1\olcut-config-protobuf-5.2.1.jar;D:\MAVEN\MavenRepository\com\google\protobuf\protobuf-java\3.19.6\protobuf-java-3.19.6.jar;D:\MAVEN\MavenRepository\org\tribuo\tribuo-data\4.3.1\tribuo-data-4.3.1.jar;D:\MAVEN\MavenRepository\org\tribuo\tribuo-util-tokenization\4.3.1\tribuo-util-tokenization-4.3.1.jar;D:\MAVEN\MavenRepository\com\opencsv\opencsv\5.7.1\opencsv-5.7.1.jar;D:\MAVEN\MavenRepository\org\apache\commons\commons-text\1.10.0\commons-text-1.10.0.jar;D:\MAVEN\MavenRepository\commons-beanutils\commons-beanutils\1.9.4\commons-beanutils-1.9.4.jar;D:\MAVEN\MavenRepository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;D:\MAVEN\MavenRepository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\MAVEN\MavenRepository\org\apache\commons\commons-lang3\3.12.0\commons-lang3-3.12.0.jar;D:\MAVEN\MavenRepository\org\tribuo\tribuo-math\4.3.1\tribuo-math-4.3.1.jar;D:\MAVEN\MavenRepository\org\tribuo\tribuo-clustering-core\4.3.1\tribuo-clustering-core-4.3.1.jar;D:\MAVEN\MavenRepository\org\tribuo\tribuo-util-infotheory\4.3.1\tribuo-util-infotheory-4.3.1.jar;D:\MAVEN\MavenRepository\com\oracle\labs\olcut\olcut-core\5.2.1\olcut-core-5.2.1.jar;D:\MAVEN\MavenRepository\org\jline\jline-terminal\3.21.0\jline-terminal-3.21.0.jar;D:\MAVEN\MavenRepository\org\jline\jline-reader\3.21.0\jline-reader-3.21.0.jar;D:\MAVEN\MavenRepository\org\jline\jline-builtins\3.21.0\jline-builtins-3.21.0.jar;D:\MAVEN\MavenRepository\org\jline\jline-style\3.21.0\jline-style-3.21.0.jar;D:\MAVEN\MavenRepository\org\jline\jline-terminal-jansi\3.21.0\jline-terminal-jansi-3.21.0.jar;D:\MAVEN\MavenRepository\org\fusesource\jansi\jansi\2.4.0\jansi-2.4.0.jar;D:\MAVEN\MavenRepository\cn\xiaoandcai\JsonDiff\1.2.1\JsonDiff-1.2.1.jar;D:\MAVEN\MavenRepository\com\alibaba\fastjson2\fastjson2\2.0.7\fastjson2-2.0.7.jar;D:\MAVEN\MavenRepository\org\apache\poi\poi\5.2.3\poi-5.2.3.jar;D:\MAVEN\MavenRepository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;D:\MAVEN\MavenRepository\org\apache\commons\commons-collections4\4.4\commons-collections4-4.4.jar;D:\MAVEN\MavenRepository\commons-io\commons-io\2.11.0\commons-io-2.11.0.jar;D:\MAVEN\MavenRepository\com\zaxxer\SparseBitSet\1.2\SparseBitSet-1.2.jar;D:\MAVEN\MavenRepository\org\apache\logging\log4j\log4j-api\2.17.2\log4j-api-2.17.2.jar;D:\MAVEN\MavenRepository\org\apache\poi\poi-ooxml\5.2.3\poi-ooxml-5.2.3.jar;D:\MAVEN\MavenRepository\org\apache\poi\poi-ooxml-lite\5.2.3\poi-ooxml-lite-5.2.3.jar;D:\MAVEN\MavenRepository\org\apache\xmlbeans\xmlbeans\5.1.1\xmlbeans-5.1.1.jar;D:\MAVEN\MavenRepository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;D:\MAVEN\MavenRepository\org\apache\commons\commons-compress\1.21\commons-compress-1.21.jar;D:\MAVEN\MavenRepository\com\github\virtuald\curvesapi\1.07\curvesapi-1.07.jar;D:\MAVEN\MavenRepository\com\alibaba\easyexcel\3.3.2\easyexcel-3.3.2.jar;D:\MAVEN\MavenRepository\com\alibaba\easyexcel-core\3.3.2\easyexcel-core-3.3.2.jar;D:\MAVEN\MavenRepository\com\alibaba\easyexcel-support\3.3.2\easyexcel-support-3.3.2.jar;D:\MAVEN\MavenRepository\org\apache\poi\poi-ooxml-schemas\4.1.2\poi-ooxml-schemas-4.1.2.jar;D:\MAVEN\MavenRepository\org\apache\commons\commons-csv\1.8\commons-csv-1.8.jar;D:\MAVEN\MavenRepository\org\ehcache\ehcache\3.9.9\ehcache-3.9.9.jar;D:\MAVEN\MavenRepository\org\apache\httpcomponents\client5\httpclient5\5.2.1\httpclient5-5.2.1.jar;D:\MAVEN\MavenRepository\org\apache\httpcomponents\core5\httpcore5\5.1.3\httpcore5-5.1.3.jar;D:\MAVEN\MavenRepository\org\apache\httpcomponents\core5\httpcore5-h2\5.1.3\httpcore5-h2-5.1.3.jar;D:\MAVEN\MavenRepository\cn\hutool\hutool-http\5.8.22\hutool-http-5.8.22.jar;D:\MAVEN\MavenRepository\cn\hutool\hutool-core\5.8.22\hutool-core-5.8.22.jar;D:\MAVEN\MavenRepository\cn\hutool\hutool-all\5.8.22\hutool-all-5.8.22.jar;D:\MAVEN\MavenRepository\redis\clients\jedis\5.0.0\jedis-5.0.0.jar;D:\MAVEN\MavenRepository\org\apache\commons\commons-pool2\2.11.1\commons-pool2-2.11.1.jar;D:\MAVEN\MavenRepository\org\json\json\20230618\json-20230618.jar;D:\MAVEN\MavenRepository\com\google\code\gson\gson\2.8.9\gson-2.8.9.jar;D:\MAVEN\MavenRepository\com\alibaba\fastjson\1.2.67\fastjson-1.2.67.jar;D:\MAVEN\MavenRepository\org\projectlombok\lombok\1.18.24\lombok-1.18.24.jar;D:\MAVEN\MavenRepository\org\springframework\cloud\spring-cloud-starter-netflix-hystrix\2.2.10.RELEASE\spring-cloud-starter-netflix-hystrix-2.2.10.RELEASE.jar;D:\MAVEN\MavenRepository\org\springframework\cloud\spring-cloud-starter\2.2.9.RELEASE\spring-cloud-starter-2.2.9.RELEASE.jar;D:\MAVEN\MavenRepository\org\springframework\cloud\spring-cloud-context\2.2.9.RELEASE\spring-cloud-context-2.2.9.RELEASE.jar;D:\MAVEN\MavenRepository\org\springframework\security\spring-security-crypto\5.6.3\spring-security-crypto-5.6.3.jar;D:\MAVEN\MavenRepository\org\springframework\cloud\spring-cloud-commons\2.2.9.RELEASE\spring-cloud-commons-2.2.9.RELEASE.jar;D:\MAVEN\MavenRepository\org\springframework\security\spring-security-rsa\1.0.9.RELEASE\spring-security-rsa-1.0.9.RELEASE.jar;D:\MAVEN\MavenRepository\org\bouncycastle\bcpkix-jdk15on\1.64\bcpkix-jdk15on-1.64.jar;D:\MAVEN\MavenRepository\org\bouncycastle\bcprov-jdk15on\1.64\bcprov-jdk15on-1.64.jar;D:\MAVEN\MavenRepository\org\springframework\cloud\spring-cloud-netflix-hystrix\2.2.10.RELEASE\spring-cloud-netflix-hystrix-2.2.10.RELEASE.jar;D:\MAVEN\MavenRepository\org\springframework\boot\spring-boot-starter-aop\2.6.7\spring-boot-starter-aop-2.6.7.jar;D:\MAVEN\MavenRepository\org\springframework\cloud\spring-cloud-netflix-ribbon\2.2.10.RELEASE\spring-cloud-netflix-ribbon-2.2.10.RELEASE.jar;D:\MAVEN\MavenRepository\org\springframework\cloud\spring-cloud-netflix-archaius\2.2.10.RELEASE\spring-cloud-netflix-archaius-2.2.10.RELEASE.jar;D:\MAVEN\MavenRepository\org\springframework\cloud\spring-cloud-starter-netflix-archaius\2.2.10.RELEASE\spring-cloud-starter-netflix-archaius-2.2.10.RELEASE.jar;D:\MAVEN\MavenRepository\com\netflix\archaius\archaius-core\0.7.7\archaius-core-0.7.7.jar;D:\MAVEN\MavenRepository\com\google\code\findbugs\jsr305\3.0.1\jsr305-3.0.1.jar;D:\MAVEN\MavenRepository\commons-configuration\commons-configuration\1.8\commons-configuration-1.8.jar;D:\MAVEN\MavenRepository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;D:\MAVEN\MavenRepository\com\netflix\hystrix\hystrix-core\1.5.18\hystrix-core-1.5.18.jar;D:\MAVEN\MavenRepository\com\netflix\hystrix\hystrix-serialization\1.5.18\hystrix-serialization-1.5.18.jar;D:\MAVEN\MavenRepository\com\fasterxml\jackson\module\jackson-module-afterburner\2.13.2\jackson-module-afterburner-2.13.2.jar;D:\MAVEN\MavenRepository\com\fasterxml\jackson\core\jackson-core\2.13.2\jackson-core-2.13.2.jar;D:\MAVEN\MavenRepository\com\fasterxml\jackson\core\jackson-annotations\2.13.2\jackson-annotations-2.13.2.jar;D:\MAVEN\MavenRepository\com\netflix\hystrix\hystrix-metrics-event-stream\1.5.18\hystrix-metrics-event-stream-1.5.18.jar;D:\MAVEN\MavenRepository\com\netflix\hystrix\hystrix-javanica\1.5.18\hystrix-javanica-1.5.18.jar;D:\MAVEN\MavenRepository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;D:\MAVEN\MavenRepository\org\aspectj\aspectjweaver\1.9.7\aspectjweaver-1.9.7.jar;D:\MAVEN\MavenRepository\io\reactivex\rxjava-reactive-streams\1.2.1\rxjava-reactive-streams-1.2.1.jar;D:\MAVEN\MavenRepository\io\reactivex\rxjava\1.3.8\rxjava-1.3.8.jar;D:\MAVEN\MavenRepository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;D:\MAVEN\MavenRepository\org\hdrhistogram\HdrHistogram\2.1.12\HdrHistogram-2.1.12.jar;D:\idea\IntelliJ IDEA 2021.3\lib\idea_rt.jar" com.example.springbootdame.PersonalAssistantApplication
Connected to the target VM, address: '127.0.0.1:55698', transport: 'socket'
2024-01-16 15:44:01.575 [al-service] [main] WARN  [org.springframework.context.annotation.AnnotationConfigApplicationContext] -Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
2024-01-16 15:44:01.581 [al-service] [main] INFO  [org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener] -

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2024-01-16 15:44:01.603 [al-service] [main] ERROR [org.springframework.boot.SpringApplication] -Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:597)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:270)
	at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:762)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:567)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:164)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:212)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:117)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:74)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85)
	at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:339)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:297)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
	at com.example.springbootdame.PersonalAssistantApplication.main(PersonalAssistantApplication.java:12)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485)
	at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.buildLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:232)
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.findLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:210)
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(InitDestroyAnnotationBeanPostProcessor.java:149)
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:305)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1116)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
	... 30 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.getDeclaredMethods(Class.java:1975)
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467)
	... 37 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 41 common frames omitted
2024-01-16 15:44:01.606 [al-service] [main] ERROR [org.springframework.boot.SpringApplication] -Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:597)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:270)
	at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:762)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:567)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:164)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:212)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:117)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:74)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85)
	at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:339)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:297)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
	at com.example.springbootdame.PersonalAssistantApplication.main(PersonalAssistantApplication.java:12)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485)
	at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.buildLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:232)
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.findLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:210)
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(InitDestroyAnnotationBeanPostProcessor.java:149)
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:305)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1116)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
	... 30 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.getDeclaredMethods(Class.java:1975)
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467)
	... 37 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 41 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:55698', transport: 'socket'

Process finished with exit code 1
View Code

报错原因是缺失特定路径下的类org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata,如下所示:

 

需要解决此问题,自定义此类即可,注意一定要定义成框架所需的包路径(package org.springframework.boot.context.properties;):

  1 package org.springframework.boot.context.properties;
  2 
  3 import org.springframework.beans.BeansException;
  4 import org.springframework.beans.factory.config.BeanDefinition;
  5 import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
  6 import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
  7 import org.springframework.beans.factory.support.BeanDefinitionRegistry;
  8 import org.springframework.beans.factory.support.GenericBeanDefinition;
  9 import org.springframework.beans.factory.support.RootBeanDefinition;
 10 import org.springframework.context.ApplicationContext;
 11 import org.springframework.context.ApplicationContextAware;
 12 import org.springframework.context.ConfigurableApplicationContext;
 13 import org.springframework.core.annotation.AnnotationUtils;
 14 import org.springframework.util.ClassUtils;
 15 import org.springframework.util.ReflectionUtils;
 16 
 17 import java.lang.annotation.Annotation;
 18 import java.lang.reflect.Method;
 19 import java.util.HashMap;
 20 import java.util.Map;
 21 import java.util.concurrent.atomic.AtomicReference;
 22 
 23 /**
 24  * @Author: mingming.chen
 25  * @Date: 2024/1/15 14 26
 26  * @Description:
 27  **/
 28 public class ConfigurationBeanFactoryMetadata implements BeanFactoryPostProcessor {
 29 
 30     private ConfigurableListableBeanFactory beanFactory;
 31 
 32     private Map<String, MetaData> beans = new HashMap<String, MetaData>();
 33 
 34     @Override
 35     public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
 36             throws BeansException {
 37         this.beanFactory = beanFactory;
 38         for (String name : beanFactory.getBeanDefinitionNames()) {
 39             BeanDefinition definition = beanFactory.getBeanDefinition(name);
 40             String method = definition.getFactoryMethodName();
 41             String bean = definition.getFactoryBeanName();
 42             if (method != null && bean != null) {
 43                 this.beans.put(name, new MetaData(bean, method));
 44             }
 45         }
 46     }
 47 
 48     public <A extends Annotation> Map<String, Object> getBeansWithFactoryAnnotation(
 49             Class<A> type) {
 50         Map<String, Object> result = new HashMap<String, Object>();
 51         for (String name : this.beans.keySet()) {
 52             if (findFactoryAnnotation(name, type) != null) {
 53                 result.put(name, this.beanFactory.getBean(name));
 54             }
 55         }
 56         return result;
 57     }
 58 
 59     public <A extends Annotation> A findFactoryAnnotation(String beanName,
 60                                                           Class<A> type) {
 61         Method method = findFactoryMethod(beanName);
 62         return (method == null ? null : AnnotationUtils.findAnnotation(method, type));
 63     }
 64 
 65     private Method findFactoryMethod(String beanName) {
 66         if (!this.beans.containsKey(beanName)) {
 67             return null;
 68         }
 69         final AtomicReference<Method> found = new AtomicReference<Method>(null);
 70         MetaData meta = this.beans.get(beanName);
 71         final String factory = meta.getMethod();
 72         Class<?> type = this.beanFactory.getType(meta.getBean());
 73         ReflectionUtils.doWithMethods(type, new ReflectionUtils.MethodCallback() {
 74             @Override
 75             public void doWith(Method method)
 76                     throws IllegalArgumentException, IllegalAccessException {
 77                 if (method.getName().equals(factory)) {
 78                     found.compareAndSet(null, method);
 79                 }
 80             }
 81         });
 82         return found.get();
 83     }
 84 
 85     private static class MetaData {
 86 
 87         private String bean;
 88 
 89         private String method;
 90 
 91         MetaData(String bean, String method) {
 92             this.bean = bean;
 93             this.method = method;
 94         }
 95 
 96         public String getBean() {
 97             return this.bean;
 98         }
 99 
100         public String getMethod() {
101             return this.method;
102         }
103 
104     }
105 
106 }
View Code

四、版本匹配安全检查问题

此时,同样启动项目,报以下错误,并中断进程:

 

 

如上所示,由于spring-cloud-starter-netflix-hystrix 2021年后不更新,此依赖包对应的springCloud版本和springboot版本不匹配,会报版本不匹配异常,需要禁用安全检查功能,如下配置在application.yml文件中:

spring:
  cloud:
    compatibility-verifier:
       enabled: false

检查配置说明:

兼容性验证器是Spring Cloud框架中的一个功能,用于确保所使用的Spring Boot版本与Spring Cloud版本兼容。当Spring Boot版本与Spring Cloud版本不兼容时,可能会导致应用程序在运行时出现问题。

在上述代码中,cloud.compatibility-verifier.enabled属性被设置为false,意味着禁用了兼容性验证器。这意味着应用程序将不再执行Spring Boot与Spring Cloud版本的兼容性检查。

禁用兼容性验证器可能会导致以下问题:

  1. 不兼容的Spring Boot和Spring Cloud版本可能导致应用程序在运行时出现错误或异常。
  2. 可能会错过一些Spring Cloud提供的新功能或修复的问题。

因此,在禁用兼容性验证器之前,应该确保所使用的Spring Boot版本与Spring Cloud版本兼容,并且了解可能的风险和影响。

五、测试验证

  1. 熔断;
  2. 降级;
  3. 线程池隔离:并发数超过设置线程池个数请求进行降级;

六、结论

完成以上前四步即可在springboot2.6.x和2.7.x使用hystrix组件。

 

标签:java,springboot,hystrix,jar,springframework,MAVEN,org,2.7,MavenRepository
From: https://www.cnblogs.com/chenmingming0225/p/17980039

相关文章

  • [Windows] 视频拍摄必备神器,桌面提词器(TelePrompter)-2.7.1
    随着短视频内容的兴起,越来越多的小伙伴开始尝试拍摄视频。但没有足够的经验,可能面对镜头就懵了,不仅磕巴,还会忘词。今天介绍的这款工具是主持人、记者常用的桌面提词器,有做短视频或直播的小伙伴可以试试这款免费工具。TelePrompter是一款易于使用、功能强大的现代Windows文本/演......
  • springboot自定义更换启动banner动画
    springboot自定义更换启动banner动画......
  • SpringBoot项目通过注解快速解决,字典翻译,响应数据加密,数据脱敏等问题
    简介在几乎所有SpringBoot项目中都会面临字典翻译,接口数据加密,数据脱敏的问题。在每个接口中单独的解决会非常繁琐,因此接下来介绍一下怎么通过注解快速解决这些问题。实现步骤1.引入maven坐标<dependency><groupId>io.gitee.gltqe</groupId>......
  • SpringBoot集成MybatisPlus
    1、添加依赖<!--mybatis-plus启动器--><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId></dependency><!--mybatis-plus代码生成器--><depe......
  • 在 SpringBoot 项目中使用 MDC 实现日志 traceId 的统一
    前言在项目中,对于每一次请求,我们都需要一个traceId将整个请求链路串联起来,这样就会很方便我们根据日志排查问题。但是如果每次打印日志都需要手动传递traceId参数,也会很麻烦,MDC就是为了解决这个场景而使用的。注:这里我们使用slf4j+logbacklogback配置logback.xml......
  • RabbitMQ学习五 springboot连接RabbitMQ
    一、入门引入依赖在springboot中引入spring-amqp-starter<!--amqp的起步依赖--><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId></dependency>编写配置文件spring:rabbitmq......
  • 面试官:SpringBoot如何实现缓存预热?
    缓存预热是指在SpringBoot项目启动时,预先将数据加载到缓存系统(如Redis)中的一种机制。那么问题来了,在SpringBoot项目启动之后,在什么时候?在哪里可以将数据加载到缓存系统呢?实现方案概述在SpringBoot启动之后,可以通过以下手段实现缓存预热:使用启动监听事件实现缓存预热。使......
  • springboot多模块项目(微服务项目)正确打包(jar)方式
    大致步骤新建一个springboot项目名称为父亲添加父快捷方式。新建子模块,子模块同时插入新建springboot的项目,依次创建enty和web模块(关键是并配置好pom文件)web模块依赖于entiy模块中的实体类,创建测试控制器,先测试项目没问题再开始打包(jar)开始打包测试jar是否有用创建项目注意点:子模......
  • springBoot项目正确认识打war包方式(含打包代码链接)
    一:新建一个普普通通的springBoot项目二:并且编写测试controller@RequestMapping@RestControllerpublicclassController{@RequestMapping("/zzh")publicStringtoString(){return"zzh666";}}三:改造启动类(重点)主要就是继承SpringBootServletInitiali......
  • springboot整合springSecurity入门案例(实现登录,记住我等常用标签使用)
    一,整合进依赖每个依赖都标了注释,大家可以按照自己需要的来添加,置于配置问件啥的,大家可以参考springboot+mybatisplus+redis整合(附上脚手架完整代码)<!--主要就是加了这个依赖--><dependency><groupId>org.springframework.security</groupId><artifact......