我有一个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中找不到有用的东西。是否有人遇到过这个问题?
答案 0 :(得分:4)
更新:Finchley M5已经发布。它与Boot 2.0 M7兼容。
在撰写本文时,Spring Cloud尚未与Spring Boot 2.0.0.M7兼容,即使在快照中也是如此。如果你想使用Spring Cloud,你现在需要坚持使用Spring Boot 2.0.0.M6。
答案 1 :(得分:0)
同时,如果您可以牺牲执行器,请尝试将其从依赖项中删除。它对我有用。