java—为什么在添加@enableautoconfiguration时,SpringMVC应用程序和SpringBootActuator出现异常

kuhbmx9i  于 2021-07-23  发布在  Java
关注(0)|答案(1)|浏览(429)

我有一个springmvc应用程序,我正在尝试添加springboot执行器以获得性能指标。我在tomcat服务器上运行它时遇到了一个异常。有谁能帮我把SpringBootActuator 2.4.2引入Spring5.2.8来获取性能指标吗?Spring版本:5.2.8。释放Spring启动致动器版本:2.4.2

@Configuration
@EnableWebMvc
@EnableAutoConfiguration
@Import(EndpointAutoConfiguration.class)
@PropertySource(value = { "classpath:application.properties" })
public class DemoActuatorConfig{

}

例外情况:

Feb 11, 2021 9:05:02 PM org.apache.catalina.core.ApplicationContext log
SEVERE: Servlet.init() for servlet [spring] threw exception
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.springmvc.actuator.demo2.DemoActuatorConfig]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.config.ConfigurableListableBeanFactory.getApplicationStartup()Lorg/springframework/core/metrics/ApplicationStartup;
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:609)
    at org.springframework.context.annotation.ConfigurationClassParser.access$800(ConfigurationClassParser.java:110)
    at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:811)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
    at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:808)
    at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:779)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:192)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:319)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:702)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:668)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:716)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:591)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:530)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:170)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1134)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1089)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:983)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4876)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5185)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3763)
    at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:299)
    at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5535)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1353)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1357)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1357)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1335)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NoSuchMethodError: org.springframework.beans.factory.config.ConfigurableListableBeanFactory.getApplicationStartup()Lorg/springframework/core/metrics/ApplicationStartup;
    at org.springframework.boot.actuate.autoconfigure.startup.StartupEndpointAutoConfiguration$ApplicationStartupCondition.getMatchOutcome(StartupEndpointAutoConfiguration.java:63)
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:225)
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:599)
    ... 39 more
ckx4rj1h

ckx4rj1h1#

不能将springboot2.4.x与springframework5.2.x一起使用。您使用的是SpringBoot2.4.2,如文档中所述,它需要SpringFramework 5.3.3或更高版本。

相关问题