【发布时间】:2017-08-19 00:59:28
【问题描述】:
我想将 spring boot 执行器添加到我的应用程序中,但是当我添加此依赖项时
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.0.0.M3</version>
</dependency>
我收到以下错误
java.lang.reflect.InvocationTargetException 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 (...) 原因:org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为“org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration$ManagementWebSecurityConfigurerAdapter”的bean时出错:通过方法“setObjectPostProcessor”参数0表示的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有“org.springframework.security.config.annotation.ObjectPostProcessor”类型的合格 bean 可用:预计至少有 1 个有资格作为自动装配候选者的 bean。依赖注解:(..._
原因:org.springframework.beans.factory.NoSuchBeanDefinitionException:没有可用的“org.springframework.security.config.annotation.ObjectPostProcessor”类型的合格bean:预计至少有1个有资格作为自动装配候选者的bean。依赖注解: 在 org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1486) 在 org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1097) 在 org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1058) 在 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ... 25 更多
我发现其他开发人员也有同样的问题,但我找不到与弹簧启动执行器有关的问题。 我跟着这个教程 http://www.baeldung.com/spring-boot-actuators
弹簧执行器应该可以开箱即用,所以当我添加这个依赖项时它应该可以正常工作。
这是 2.0.0M3 spring 框架的 bug 吗?
编辑
我遵循一个建议,并从https://start.spring.io/ 创建了一个简单的项目,但它也会引发错误,但这次只有一个
java.lang.ClassCastException: org.springframework.boot.context.event.ApplicationFailedEvent 不能转换为 org.springframework.boot.web.context.WebServerInitializedEvent 在 org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:159) [spring-context-5.0.0.RC3.jar:5.0.0.RC3] 在 org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-5.0.0.RC3.jar:5.0.0.RC3] 在 org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) [spring-context-5.0.0.RC3.jar:5.0.0.RC3] 在 org.springframework.boot.context.event.EventPublishingRunListener.finished(EventPublishingRunListener.java:114) [spring-boot-2.0.0.M3.jar:2.0.0.M3] 在 org.springframework.boot.SpringApplicationRunListeners.callFinishedListener(SpringApplicationRunListeners.java:79) [spring-boot-2.0.0.M3.jar:2.0.0.M3] 在 org.springframework.boot.SpringApplicationRunListeners.finished(SpringApplicationRunListeners.java:72) [spring-boot-2.0.0.M3.jar:2.0.0.M3] 在 org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:803) [spring-boot-2.0.0.M3.jar:2.0.0.M3] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:338) [spring-boot-2.0.0.M3.jar:2.0.0.M3] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M3.jar:2.0.0.M3] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.M3.jar:2.0.0.M3] 在 com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na]
它根本没有启动,但我更改为 1.5.6 版本,它工作正常,所以我认为这是 2.0.0M3 问题。
【问题讨论】: