一、pom.xml需要引入的依赖
二、项目开启熔断器开关
2.1 注解方式
2.2 xml方式
三、依赖类缺失问题
四、版本匹配安全检查问题
五、测试验证
六、结论
一、pom.xml需要引入的依赖
pom.xml
org.springframework.boot
spring-boot-starter-parent
2.6.7
org.springframework.cloud
spring-cloud-starter-netflix-hystrix
2.2.10.RELEASE
org.hdrhistogram
HdrHistogram
2.1.12
二、项目开启熔断器开关
2.1 注解方式
@EnableHystrix
@EnableCircuitBreaker
注:项目启动类中加上以上注解,以上两者取其一即可;
2.2 xml方式
以上注解方式底层就是实例化此类:
三、依赖类缺失问题
此时运行项目将报以下错误:
errpr.log
D:JDKjdk1.8binjava.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:Usersmingming.chenAppDataLocalJetBrainsIntelliJIdea2021.3captureAgentdebugger-agent.jar -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath "D:JDKjdk1.8jrelibcharsets.jar;D:JDKjdk1.8jrelibdeploy.jar;D:JDKjdk1.8jrelibextaccess-bridge-64.jar;D:JDKjdk1.8jrelibextcldrdata.jar;D:JDKjdk1.8jrelibextdnsns.jar;D:JDKjdk1.8jrelibextjaccess.jar;D:JDKjdk1.8jrelibextjfxrt.jar;D:JDKjdk1.8jrelibextlocaledata.jar;D:JDKjdk1.8jrelibextnashorn.jar;D:JDKjdk1.8jrelibextsunec.jar;D:JDKjdk1.8jrelibextsunjce_provider.jar;D:JDKjdk1.8jrelibextsunmscapi.jar;D:JDKjdk1.8jrelibextsunpkcs11.jar;D:JDKjdk1.8jrelibextzipfs.jar;D:JDKjdk1.8jrelibjavaws.jar;D:JDKjdk1.8jrelibjce.jar;D:JDKjdk1.8jrelibjfr.jar;D:JDKjdk1.8jrelibjfxswt.jar;D:JDKjdk1.8jrelibjsse.jar;D:JDKjdk1.8jrelibmanagement-agent.jar;D:JDKjdk1.8jrelibplugin.jar;D:JDKjdk1.8jrelibresources.jar;D:JDKjdk1.8jrelibrt.jar;D:LocalRepositionoherprojecttestProjectPersonalAssistanttargetclasses;D:MAVENMavenRepositoryorgspringframeworkbootspring-boot-starter2.6.7spring-boot-starter-2.6.7.jar;D:MAVENMavenRepositoryorgspringframeworkbootspring-boot2.6.7spring-boot-2.6.7.jar;D:MAVENMavenRepositoryorgspringframeworkspring-context5.3.19spring-context-5.3.19.jar;D:MAVENMavenRepositoryorgspringframeworkbootspring-boot-autoconfigure2.6.7spring-boot-autoconfigure-2.6.7.jar;D:MAVENMavenRepositoryorgspringframeworkbootspring-boot-starter-logging2.6.7spring-boot-starter-logging-2.6.7.jar;D:MAVENMavenRepositorychqoslogbacklogback-classic1.2.11logback-classic-1.2.11.jar;D:MAVENMavenRepositorychqoslogbacklogback-core1.2.11logback-core-1.2.11.jar;D:MAVENMavenRepositoryorgapachelogginglog4jlog4j-to-slf4j2.17.2log4j-to-slf4j-2.17.2.jar;D:MAVENMavenRepositoryorgslf4jjul-to-slf4j1.7.36jul-to-slf4j-1.7.36.jar;D:MAVENMavenRepositoryjakartaannotationjakarta.annotation-api1.3.5jakarta.annotation-api-1.3.5.jar;D:MAVENMavenRepositoryorgspringframeworkspring-core5.3.19spring-core-5.3.19.jar;D:MAVENMavenRepositoryorgspringframeworkspring-jcl5.3.19spring-jcl-5.3.19.jar;D:MAVENMavenRepositoryorgyamlsnakeyaml1.29snakeyaml-1.29.jar;D:MAVENMavenRepositoryorgspringframeworkbootspring-boot-starter-test2.6.7spring-boot-starter-test-2.6.7.jar;D:MAVENMavenRepositoryorgspringframeworkbootspring-boot-test2.6.7spring-boot-test-2.6.7.jar;D:MAVENMavenRepositoryorgspringframeworkbootspring-boot-test-autoconfigure2.6.7spring-boot-test-autoconfigure-2.6.7.jar;D:MAVENMavenRepositorycomjaywayjsonpathjson-path2.6.0json-path-2.6.0.jar;D:MAVENMavenRepositorynetminidevjson-smart2.4.8json-smart-2.4.8.jar;D:MAVENMavenRepositorynetminidevaccessors-smart2.4.8accessors-smart-2.4.8.jar;D:MAVENMavenRepositoryjakartaxmlbindjakarta.xml.bind-api2.3.3jakarta.xml.bind-api-2.3.3.jar;D:MAVENMavenRepositoryjakartaactivationjakarta.activation-api1.2.2jakarta.activation-api-1.2.2.jar;D:MAVENMavenRepositoryorgassertjassertj-core3.21.0assertj-core-3.21.0.jar;D:MAVENMavenRepositoryorghamcresthamcrest2.2hamcrest-2.2.jar;D:MAVENMavenRepositoryorgjunitjupiterjunit-jupiter5.8.2junit-jupiter-5.8.2.jar;D:MAVENMavenRepositoryorgjunitjupiterjunit-jupiter-api5.8.2junit-jupiter-api-5.8.2.jar;D:MAVENMavenRepositoryorgopentest4jopentest4j1.2.0opentest4j-1.2.0.jar;D:MAVENMavenRepositoryorgjunitplatformjunit-platform-commons1.8.2junit-platform-commons-1.8.2.jar;D:MAVENMavenRepositoryorgapiguardianapiguardian-api1.1.2apiguardian-api-1.1.2.jar;D:MAVENMavenRepositoryorgjunitjupiterjunit-jupiter-params5.8.2junit-jupiter-params-5.8.2.jar;D:MAVENMavenRepositoryorgjunitjupiterjunit-jupiter-engine5.8.2junit-jupiter-engine-5.8.2.jar;D:MAVENMavenRepositoryorgjunitplatformjunit-platform-engine1.8.2junit-platform-engine-1.8.2.jar;D:MAVENMavenRepositoryorgmockitomockito-core4.0.0mockito-core-4.0.0.jar;D:MAVENMavenRepositorynetbytebuddybyte-buddy1.11.22byte-buddy-1.11.22.jar;D:MAVENMavenRepositorynetbytebuddybyte-buddy-agent1.11.22byte-buddy-agent-1.11.22.jar;D:MAVENMavenRepositoryorgobjenesisobjenesis3.2objenesis-3.2.jar;D:MAVENMavenRepositoryorgmockitomockito-junit-jupiter4.0.0mockito-junit-jupiter-4.0.0.jar;D:MAVENMavenRepositoryorgskyscreamerjsonassert1.5.0jsonassert-1.5.0.jar;D:MAVENMavenRepositorycomvaadinexternalgoogleandroid-json.0.20131108.vaadin1android-json-0.0.20131108.vaadin1.jar;D:MAVENMavenRepositoryorgspringframeworkspring-test5.3.19spring-test-5.3.19.jar;D:MAVENMavenRepositoryorgxmlunitxmlunit-core2.8.4xmlunit-core-2.8.4.jar;D:MAVENMavenRepositoryorgspringframeworkbootspring-boot-starter-web2.6.7spring-boot-starter-web-2.6.7.jar;D:MAVENMavenRepositoryorgspringframeworkbootspring-boot-starter-json2.6.7spring-boot-starter-json-2.6.7.jar;D:MAVENMavenRepositorycomfasterxmljacksoncorejackson-databind2.13.2.1jackson-databind-2.13.2.1.jar;D:MAVENMavenRepositorycomfasterxmljacksondatatypejackson-datatype-jdk82.13.2jackson-datatype-jdk8-2.13.2.jar;D:MAVENMavenRepositorycomfasterxmljacksondatatypejackson-datatype-jsr3102.13.2jackson-datatype-jsr310-2.13.2.jar;D:MAVENMavenRepositorycomfasterxmljacksonmodulejackson-module-parameter-names2.13.2jackson-module-parameter-names-2.13.2.jar;D:MAVENMavenRepositoryorgspringframeworkbootspring-boot-starter-tomcat2.6.7spring-boot-starter-tomcat-2.6.7.jar;D:MAVENMavenRepositoryorgapachetomcatembedtomcat-embed-core9.0.62tomcat-embed-core-9.0.62.jar;D:MAVENMavenRepositoryorgapachetomcatembedtomcat-embed-el9.0.62tomcat-embed-el-9.0.62.jar;D:MAVENMavenRepositoryorgapachetomcatembedtomcat-embed-websocket9.0.62tomcat-embed-websocket-9.0.62.jar;D:MAVENMavenRepositoryorgspringframeworkspring-web5.3.19spring-web-5.3.19.jar;D:MAVENMavenRepositoryorgspringframeworkspring-beans5.3.19spring-beans-5.3.19.jar;D:MAVENMavenRepositoryorgspringframeworkspring-webmvc5.3.19spring-webmvc-5.3.19.jar;D:MAVENMavenRepositoryorgspringframeworkspring-aop5.3.19spring-aop-5.3.19.jar;D:MAVENMavenRepositoryorgspringframeworkspring-expression5.3.19spring-expression-5.3.19.jar;D:MAVENMavenRepositoryorgapachemahoutmahout-math.13.0mahout-math-0.13.0.jar;D:MAVENMavenRepositoryorgapachecommonscommons-math33.2commons-math3-3.2.jar;D:MAVENMavenRepositorycomgoogleguavaguava14.0.1guava-14.0.1.jar;D:MAVENMavenRepositoryitunimidsifastutil7.0.12fastutil-7.0.12.jar;D:MAVENMavenRepositoryorgslf4jslf4j-api1.7.36slf4j-api-1.7.36.jar;D:MAVENMavenRepositorycomtdunningt-digest3.1t-digest-3.1.jar;D:MAVENMavenRepositoryorgtribuotribuo-clustering-kmeans4.3.1tribuo-clustering-kmeans-4.3.1.jar;D:MAVENMavenRepositoryorgtribuotribuo-core4.3.1tribuo-core-4.3.1.jar;D:MAVENMavenRepositoryorgtribuotribuo-util-onnx4.3.1tribuo-util-onnx-4.3.1.jar;D:MAVENMavenRepositorycomoraclelabsolcutolcut-config-protobuf5.2.1olcut-config-protobuf-5.2.1.jar;D:MAVENMavenRepositorycomgoogleprotobufprotobuf-java3.19.6protobuf-java-3.19.6.jar;D:MAVENMavenRepositoryorgtribuotribuo-data4.3.1tribuo-data-4.3.1.jar;D:MAVENMavenRepositoryorgtribuotribuo-util-tokenization4.3.1tribuo-util-tokenization-4.3.1.jar;D:MAVENMavenRepositorycomopencsvopencsv5.7.1opencsv-5.7.1.jar;D:MAVENMavenRepositoryorgapachecommonscommons-text1.10.0commons-text-1.10.0.jar;D:MAVENMavenRepositorycommons-beanutilscommons-beanutils1.9.4commons-beanutils-1.9.4.jar;D:MAVENMavenRepositorycommons-loggingcommons-logging1.2commons-logging-1.2.jar;D:MAVENMavenRepositorycommons-collectionscommons-collections3.2.2commons-collections-3.2.2.jar;D:MAVENMavenRepositoryorgapachecommonscommons-lang33.12.0commons-lang3-3.12.0.jar;D:MAVENMavenRepositoryorgtribuotribuo-math4.3.1tribuo-math-4.3.1.jar;D:MAVENMavenRepositoryorgtribuotribuo-clustering-core4.3.1tribuo-clustering-core-4.3.1.jar;D:MAVENMavenRepositoryorgtribuotribuo-util-infotheory4.3.1tribuo-util-infotheory-4.3.1.jar;D:MAVENMavenRepositorycomoraclelabsolcutolcut-core5.2.1olcut-core-5.2.1.jar;D:MAVENMavenRepositoryorgjlinejline-terminal3.21.0jline-terminal-3.21.0.jar;D:MAVENMavenRepositoryorgjlinejline-reader3.21.0jline-reader-3.21.0.jar;D:MAVENMavenRepositoryorgjlinejline-builtins3.21.0jline-builtins-3.21.0.jar;D:MAVENMavenRepositoryorgjlinejline-style3.21.0jline-style-3.21.0.jar;D:MAVENMavenRepositoryorgjlinejline-terminal-jansi3.21.0jline-terminal-jansi-3.21.0.jar;D:MAVENMavenRepositoryorgfusesourcejansijansi2.4.0jansi-2.4.0.jar;D:MAVENMavenRepositorycnxiaoandcaiJsonDiff1.2.1JsonDiff-1.2.1.jar;D:MAVENMavenRepositorycomalibabafastjson2fastjson22.0.7fastjson2-2.0.7.jar;D:MAVENMavenRepositoryorgapachepoipoi5.2.3poi-5.2.3.jar;D:MAVENMavenRepositorycommons-codeccommons-codec1.15commons-codec-1.15.jar;D:MAVENMavenRepositoryorgapachecommonscommons-collections44.4commons-collections4-4.4.jar;D:MAVENMavenRepositorycommons-iocommons-io2.11.0commons-io-2.11.0.jar;D:MAVENMavenRepositorycomzaxxerSparseBitSet1.2SparseBitSet-1.2.jar;D:MAVENMavenRepositoryorgapachelogginglog4jlog4j-api2.17.2log4j-api-2.17.2.jar;D:MAVENMavenRepositoryorgapachepoipoi-ooxml5.2.3poi-ooxml-5.2.3.jar;D:MAVENMavenRepositoryorgapachepoipoi-ooxml-lite5.2.3poi-ooxml-lite-5.2.3.jar;D:MAVENMavenRepositoryorgapachexmlbeansxmlbeans5.1.1xmlbeans-5.1.1.jar;D:MAVENMavenRepositoryxml-apisxml-apis1.4.01xml-apis-1.4.01.jar;D:MAVENMavenRepositoryorgapachecommonscommons-compress1.21commons-compress-1.21.jar;D:MAVENMavenRepositorycomgithubvirtualdcurvesapi1.07curvesapi-1.07.jar;D:MAVENMavenRepositorycomalibabaeasyexcel3.3.2easyexcel-3.3.2.jar;D:MAVENMavenRepositorycomalibabaeasyexcel-core3.3.2easyexcel-core-3.3.2.jar;D:MAVENMavenRepositorycomalibabaeasyexcel-support3.3.2easyexcel-support-3.3.2.jar;D:MAVENMavenRepositoryorgapachepoipoi-ooxml-schemas4.1.2poi-ooxml-schemas-4.1.2.jar;D:MAVENMavenRepositoryorgapachecommonscommons-csv1.8commons-csv-1.8.jar;D:MAVENMavenRepositoryorgehcacheehcache3.9.9ehcache-3.9.9.jar;D:MAVENMavenRepositoryorgapachehttpcomponentsclient5httpclient55.2.1httpclient5-5.2.1.jar;D:MAVENMavenRepositoryorgapachehttpcomponentscore5httpcore55.1.3httpcore5-5.1.3.jar;D:MAVENMavenRepositoryorgapachehttpcomponentscore5httpcore5-h25.1.3httpcore5-h2-5.1.3.jar;D:MAVENMavenRepositorycnhutoolhutool-http5.8.22hutool-http-5.8.22.jar;D:MAVENMavenRepositorycnhutoolhutool-core5.8.22hutool-core-5.8.22.jar;D:MAVENMavenRepositorycnhutoolhutool-all5.8.22hutool-all-5.8.22.jar;D:MAVENMavenRepositoryredisclientsjedis5.0.0jedis-5.0.0.jar;D:MAVENMavenRepositoryorgapachecommonscommons-pool22.11.1commons-pool2-2.11.1.jar;D:MAVENMavenRepositoryorgjsonjson20230618json-20230618.jar;D:MAVENMavenRepositorycomgooglecodegsongson2.8.9gson-2.8.9.jar;D:MAVENMavenRepositorycomalibabafastjson1.2.67fastjson-1.2.67.jar;D:MAVENMavenRepositoryorgprojectlomboklombok1.18.24lombok-1.18.24.jar;D:MAVENMavenRepositoryorgspringframeworkcloudspring-cloud-starter-netflix-hystrix2.2.10.RELEASEspring-cloud-starter-netflix-hystrix-2.2.10.RELEASE.jar;D:MAVENMavenRepositoryorgspringframeworkcloudspring-cloud-starter2.2.9.RELEASEspring-cloud-starter-2.2.9.RELEASE.jar;D:MAVENMavenRepositoryorgspringframeworkcloudspring-cloud-context2.2.9.RELEASEspring-cloud-context-2.2.9.RELEASE.jar;D:MAVENMavenRepositoryorgspringframeworksecurityspring-security-crypto5.6.3spring-security-crypto-5.6.3.jar;D:MAVENMavenRepositoryorgspringframeworkcloudspring-cloud-commons2.2.9.RELEASEspring-cloud-commons-2.2.9.RELEASE.jar;D:MAVENMavenRepositoryorgspringframeworksecurityspring-security-rsa1.0.9.RELEASEspring-security-rsa-1.0.9.RELEASE.jar;D:MAVENMavenRepositoryorgbouncycastlebcpkix-jdk15on1.64bcpkix-jdk15on-1.64.jar;D:MAVENMavenRepositoryorgbouncycastlebcprov-jdk15on1.64bcprov-jdk15on-1.64.jar;D:MAVENMavenRepositoryorgspringframeworkcloudspring-cloud-netflix-hystrix2.2.10.RELEASEspring-cloud-netflix-hystrix-2.2.10.RELEASE.jar;D:MAVENMavenRepositoryorgspringframeworkbootspring-boot-starter-aop2.6.7spring-boot-starter-aop-2.6.7.jar;D:MAVENMavenRepositoryorgspringframeworkcloudspring-cloud-netflix-ribbon2.2.10.RELEASEspring-cloud-netflix-ribbon-2.2.10.RELEASE.jar;D:MAVENMavenRepositoryorgspringframeworkcloudspring-cloud-netflix-archaius2.2.10.RELEASEspring-cloud-netflix-archaius-2.2.10.RELEASE.jar;D:MAVENMavenRepositoryorgspringframeworkcloudspring-cloud-starter-netflix-archaius2.2.10.RELEASEspring-cloud-starter-netflix-archaius-2.2.10.RELEASE.jar;D:MAVENMavenRepositorycomnetflixarchaiusarchaius-core.7.7archaius-core-0.7.7.jar;D:MAVENMavenRepositorycomgooglecodefindbugsjsr3053.0.1jsr305-3.0.1.jar;D:MAVENMavenRepositorycommons-configurationcommons-configuration1.8commons-configuration-1.8.jar;D:MAVENMavenRepositorycommons-langcommons-lang2.6commons-lang-2.6.jar;D:MAVENMavenRepositorycomnetflixhystrixhystrix-core1.5.18hystrix-core-1.5.18.jar;D:MAVENMavenRepositorycomnetflixhystrixhystrix-serialization1.5.18hystrix-serialization-1.5.18.jar;D:MAVENMavenRepositorycomfasterxmljacksonmodulejackson-module-afterburner2.13.2jackson-module-afterburner-2.13.2.jar;D:MAVENMavenRepositorycomfasterxmljacksoncorejackson-core2.13.2jackson-core-2.13.2.jar;D:MAVENMavenRepositorycomfasterxmljacksoncorejackson-annotations2.13.2jackson-annotations-2.13.2.jar;D:MAVENMavenRepositorycomnetflixhystrixhystrix-metrics-event-stream1.5.18hystrix-metrics-event-stream-1.5.18.jar;D:MAVENMavenRepositorycomnetflixhystrixhystrix-javanica1.5.18hystrix-javanica-1.5.18.jar;D:MAVENMavenRepositoryorgow2asmasm5.0.4asm-5.0.4.jar;D:MAVENMavenRepositoryorgaspectjaspectjweaver1.9.7aspectjweaver-1.9.7.jar;D:MAVENMavenRepositoryioreactivexrxjava-reactive-streams1.2.1rxjava-reactive-streams-1.2.1.jar;D:MAVENMavenRepositoryioreactivexrxjava1.3.8rxjava-1.3.8.jar;D:MAVENMavenRepositoryorgreactivestreamsreactive-streams1.0.3reactive-streams-1.0.3.jar;D:MAVENMavenRepositoryorghdrhistogramHdrHistogram2.1.12HdrHistogram-2.1.12.jar;D:ideaIntelliJ IDEA 2021.3libidea_rt.jar" com.example.springbootdame.PersonalAssistantApplication
Connect服务器托管网ed 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 Applic服务器托管网ationContext. 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
报错原因是缺失特定路径下的类org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata,如下所示:
需要解决此问题,自定义此类即可,注意一定要定义成框架所需的包路径(package org.springframework.boot.context.properties;):
ConfigurationBeanFactoryMetadata.java
package org.springframework.boot.context.properties;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
/**
* @Author: mingming.chen
* @Date: 2024/1/15 14 26
* @Description:
**/
public class ConfigurationBeanFactoryMetadata implements BeanFactoryPostProcessor {
private ConfigurableListableBeanFactory beanFactory;
private Map beans = new HashMap();
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException {
this.beanFactory = beanFactory;
for (String name : beanFactory.getBeanDefinitionNames()) {
BeanDefinition definition = beanFactory.getBeanDefinition(name);
String method = definition.getFactoryMethodName();
String bean = definition.getFactoryBeanName();
if (method != null && bean != null) {
this.beans.put(name, new MetaData(bean, method));
}
}
}
public Map getBeansWithFactoryAnnotation(
Class type) {
Map result = new HashMap();
for (String name : this.beans.keySet()) {
if (findFactoryAnnotation(name, type) != null) {
result.put(name, this.beanFactory.getBean(name));
}
}
return result;
}
public A findFactoryAnnotation(String beanName,
Class type) {
Method method = findFactoryMethod(beanName);
return (method == null ? null : AnnotationUtils.findAnnotation(method, type));
}
private Method findFactoryMethod(String beanName) {
if (!this.beans.containsKey(beanName)) {
return null;
}
final AtomicReference found = new AtomicReference(null);
MetaData meta = this.beans.get(beanName);
final String factory = meta.getMethod();
Class> type = this.beanFactory.getType(meta.getBean());
ReflectionUtils.doWithMethods(type, new ReflectionUtils.MethodCallback() {
@Override
public void doWith(Method method)
throws IllegalArgumentException, IllegalAccessException {
if (method.getName().equals(factory)) {
found.compareAndSet(null, method);
}
}
});
return found.get();
}
private static class MetaData {
private String bean;
private String method;
MetaData(String bean, String method) {
this.bean = bean;
this.method = method;
}
public String getBean() {
return this.bean;
}
public String getMethod() {
return this.method;
}
}
}
四、版本匹配安全检查问题
此时,同样启动项目,报以下错误,并中断进程:
如上所示,由于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版本的兼容性检查。
禁用兼容性验证器可能会导致以下问题:
- 不兼容的Spring Boot和Spring Cloud版本可能导致应用程序在运行时出现错误或异常。
- 可能会错过一些Spring Cloud提供的新功能或修复的问题。
因此,在禁用兼容性验证器之前,应该确保所使用的Spring Boot版本与Spring Cloud版本兼容,并且了解可能的风险和影响。
五、测试验证
- 熔断;
- 降级;
- 线程池隔离:并发数超过设置线程池个数请求进行降级;
六、结论
完成以上前四步即可在springboot2.6.x和2.7.x使用hystrix组件。
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: 【Linux】虚拟机部署与发布J2EE项目(Linux版本)
【Linux】虚拟机部署与发布J2EE项目(Linux版本) 1.准备配置环境,安装jdk 2.对要用到的文件进行解压。 2.Tomcat安装 1.解压文件 2.启动防火墙 3.开放端口 4.跟新防火墙规则 5.开启自启防火墙服务器托管网 6,开启Tomcat…