gpt4 book ai didi

java - Spring:OnEnabledEndpointCondition 只能用于返回@Endpoint 或@EndpointExtension 的@Bean 方法

转载 作者:搜寻专家 更新时间:2023-11-01 02:36:52 25 4
gpt4 key购买 nike

我有一个 pet project (社交网络 Web 应用程序),我使用 Spring Cloud 构建微服务基础设施。

我总是保留所有库的最新版本,所以目前我正在将 Spring Boot + Cloud 更新到以下版本:

springBootVersion = '2.0.0.M7'
springDataVersion = '2.0.0.M7'
springCloudVersion = 'Finchley.M4'

更新版本后,我的应用程序开始无法启动。例如,当我在 sn-user-service 中运行测试时,我得到以下堆栈跟踪:

java.lang.IllegalStateException: Failed to load ApplicationContext

at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:107)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:242)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.autoconfigure.LifecycleMvcEndpointAutoConfiguration.environmentWebEndpointExtension
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:109)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:179)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:751)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:387)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:138)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
... 24 more
Caused by: java.lang.IllegalStateException: Failed to extract endpoint id for org.springframework.cloud.autoconfigure.LifecycleMvcEndpointAutoConfiguration.environmentWebEndpointExtension
at org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnEnabledEndpointCondition.getEndpointAttributes(OnEnabledEndpointCondition.java:93)
at org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnEnabledEndpointCondition.getEndpointAttributes(OnEnabledEndpointCondition.java:80)
at org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnEnabledEndpointCondition.getMatchOutcome(OnEnabledEndpointCondition.java:48)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
... 40 more
Caused by: java.lang.IllegalStateException: OnEnabledEndpointCondition may only be used on @Bean methods that return an @Endpoint or and @EndpointExtension
at org.springframework.util.Assert.state(Assert.java:73)
at org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnEnabledEndpointCondition.getEndpointAttributes(OnEnabledEndpointCondition.java:108)
at org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnEnabledEndpointCondition.getEndpointAttributes(OnEnabledEndpointCondition.java:89)
... 43 more

问题是我在 Spring Docs 中找不到有用的东西。有人遇到过这个问题吗?

最佳答案

更新:Finchley M5 已发布。它与 Boot 2.0 M7 兼容。

在撰写本文时,Spring Cloud 还不兼容 Spring Boot 2.0.0.M7,即使在快照中也是如此。如果您想使用 Spring Cloud,您现在需要坚持使用 Spring Boot 2.0.0.M6。

关于java - Spring:OnEnabledEndpointCondition 只能用于返回@Endpoint 或@EndpointExtension 的@Bean 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47593355/

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