gpt4 book ai didi

java - 无法使用 Spring 执行器 - 创建 bean CacheMetricsRegistrarConfiguration 时出错

转载 作者:行者123 更新时间:2023-12-01 16:25:03 27 4
gpt4 key购买 nike

最近我添加了对 org.springframework.boot:spring-boot-starter-actuator 的依赖项,因为我想监视我的应用程序状态,例如 UP 等。应用程序启动我收到此异常。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: net.sf.ehcache.Ehcache.getStatistics()Lnet/sf/ehcache/statistics/StatisticsGateway;
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:138) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:422) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1694) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:137) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at cz.fischer.upe.architecture.core.core.startup.SpringApplicationRun.run(SpringApplicationRun.java:25) [classes/:?]
at ckf.upe.KtTigerApplication.main(KtTigerApplication.java:37) [classes/:?]
Caused by: java.lang.NoSuchMethodError: net.sf.ehcache.Ehcache.getStatistics()Lnet/sf/ehcache/statistics/StatisticsGateway;
at io.micrometer.core.instrument.binder.cache.EhCache2Metrics.<init>(EhCache2Metrics.java:36) ~[micrometer-core-1.0.3.jar:1.0.3]
at org.springframework.boot.actuate.metrics.cache.EhCache2CacheMeterBinderProvider.getMeterBinder(EhCache2CacheMeterBinderProvider.java:36) ~[spring-boot-actuator-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.actuate.metrics.cache.EhCache2CacheMeterBinderProvider.getMeterBinder(EhCache2CacheMeterBinderProvider.java:31) ~[spring-boot-actuator-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.actuate.metrics.cache.CacheMetricsRegistrar.lambda$getMeterBinder$0(CacheMetricsRegistrar.java:76) ~[spring-boot-actuator-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.util.LambdaSafe$Callbacks.lambda$null$3(LambdaSafe.java:307) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
.
.
.

我正在使用这个 SpringBootApplication header :

@SpringBootApplication(exclude = {
DataSourceAutoConfiguration.class,
WebMvcAutoConfiguration.class,
HibernateJpaAutoConfiguration.class
})

有人可以帮我吗?我正在运行 2.0.1.RELEASE spring boot 版本。感谢您的帮助。

最佳答案

当前 Spring Boot 千分尺 requires net.sf.ehcache:ehcache:2.10.4 。您在代码中使用了不同的 Ehcache 版本,该版本没有 net.sf.ehcache.Ehcache.getStatistics() 方法。

如果您计划使用 Spring Boot Micrometer,请使用 Ehcache 2.10.4 或更高版本。

关于java - 无法使用 Spring 执行器 - 创建 bean CacheMetricsRegistrarConfiguration 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52382315/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com