繁体   English   中英

Spring Boot 2.0.0M3弹簧执行器

[英]Spring Boot 2.0.0M3 Spring Actuator

我想将弹簧启动执行器添加到我的应用程序中,但是当我添加此依赖项时

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

我收到以下错误

在(...)处的sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处的java.lang.reflect.InvocationTargetException原因:org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为'org.springframework.boot的bean时出错。 actuate.autoconfigure.ManagementWebSecurityAutoConfiguration $ ManagementWebSecurityConfigurerAdapter':通过方法'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.doResolveDependency(DefaultListableBeanFactory.java:1097)在org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1097)在org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1486) org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)上的beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1058)...另外25个

我发现其他开发人员也遇到了同样的问题,但是我找不到与弹簧启动执行器有关的问题。 我遵循了本教程http://www.baeldung.com/spring-boot-actuators

弹簧执行器应该开箱即用,因此当我添加此依赖项时,它应该可以正常工作。

这是2.0.0M3 spring框架的错误吗?

编辑

我遵循一个建议,并从https://start.spring.io/创建了一个简单的项目,但是它也会引发错误,但是这次只有一个

java.lang.ClassCastException:无法将org.springframework.boot.context.event.ApplicationFailedEvent转换为org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster(SimpleApplicationEventMulticaster.java:159)上的org.springframework.boot.web.context.WebServerInitializedEvent )[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] at org.springframework.boot.SpringApplicationRunListeners.callFinishedListener(SpringApplicationRunListeners.java :79)[spring-boot-2.0.0.M3.jar:2.0.0.M3] at org.sp 在org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:803)上的ringframework.boot.SpringApplicationRunListeners.finished(SpringApplicationRunListeners.java:72)[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] [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。在com.example.demo.DemoApplication.main(DemoApplication.java:10)处运行(SpringApplication.java:1233)[spring-boot-2.0.0.M3.jar:2.0.0.M3] [classes /:na]

它根本没有启动,但是我更改为1.5.6版,并且工作正常,所以我想这是2.0.0M3问题。

编辑:

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

弹簧ga-rc和m2版本之间的差异

您遇到的问题很可能与您使用的“ 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>

为了在您的项目中正确添加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批注。 希望对您有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM