Spring: OnEnabledEndpointCondition can only be used for @Bean methods that return @Endpoint or @EndpointExtension

I have a pet project (a social networking web application) and I use Spring Cloud to build a microservices infrastructure.

I always keep the latest versions of all libraries, so I am currently updating Spring Boot + Cloud to the following versions:

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

After I updated the version, my application began to not start. For example, when I run tests in sn-user-service, I get the following stack trace:

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

The problem is that I cannot find anything useful in it in Spring Docs. Is there anyone who has run into this problem?

+4
2

: Finchley M5. Boot 2.0 M7.

, Spring Cloud Spring Boot 2.0.0.M7, . Spring Cloud, Spring Boot 2.0.0.M6.

+4

, , . .

0

Source: https://habr.com/ru/post/1690127/


All Articles