【问题标题】:Spring Boot 2.0.0M3 Spring ActuatorSpring Boot 2.0.0M3 弹簧执行器
【发布时间】: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 问题。

【问题讨论】:

    标签: java spring maven


    【解决方案1】:

    为了将actuator正确添加到您的项目中,请转到Spring官方文档http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready

    一个好的方法是从https://start.spring.io/ 获得一个准备好的安装项目,只需选择actuator 和项目所需的所有依赖项,选择spring boot 版本并下载项目,然后你可以比较你的pom.xml使用来自 start.pring.io 的 pom.xml 还请验证您是否使用 @SpringBootApplication 注释。希望对您有所帮助。

    【讨论】:

      【解决方案2】:

      编辑:

      M = 里程碑构建 - 可能功能不完整;应该是比较稳定的(即它不仅仅是一个夜间快照),但可能仍然存在问题。

      difference-between-springs-ga-rc-and-m2-releases

      您遇到的问题很可能与您使用的“M”版本有关。

      原答案:

      看起来像是 Spring 依赖版本之间的冲突。尝试使用 spring-boot-starter-parent 来管理所有 Spring 依赖项的版本:

      <parent>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-parent</artifactId>
          <version>1.5.6.RELEASE</version>
      </parent>
      

      来自https://projects.spring.io/spring-boot/

      在项目中开始使用 spring-boot 的推荐方法 带有依赖管理系统——

      父级将允许您省略某些依赖项的版本,因为它们将由管理系统管理,这将确保它管理的所有依赖项都是兼容的。

      所以:

      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-actuator</artifactId>
          <version>2.0.0.M3</version>
      </dependency>
      

      变成:

      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-actuator</artifactId>
      </dependency>
      

      【讨论】:

        猜你喜欢
        • 2018-04-28
        • 2018-02-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-08
        • 2017-07-29
        • 2017-07-06
        • 2014-04-07
        相关资源
        最近更新 更多