1

i would like to add spring boot actuator to my application but when i add this dependency

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

i get the following error

java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at (...) Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration$ManagementWebSecurityConfigurerAdapter': Unsatisfied dependency expressed through method 'setObjectPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: (..._
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1486) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1097) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1058) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ... 25 more

I found that other developers have had the same problem but i could not find a problem connected with spring boot actuator. I followed this tutorial http://www.baeldung.com/spring-boot-actuators

Spring actuator should work out of box, so when i add this dependency it should work fine.

Is this a 2.0.0M3 spring framework bug?

EDIT

I follow one advice and i create simple project from https://start.spring.io/ but it also throws error but this time only one

java.lang.ClassCastException: org.springframework.boot.context.event.ApplicationFailedEvent cannot be cast to org.springframework.boot.web.context.WebServerInitializedEvent at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:159) [spring-context-5.0.0.RC3.jar:5.0.0.RC3] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-5.0.0.RC3.jar:5.0.0.RC3] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) [spring-context-5.0.0.RC3.jar:5.0.0.RC3] at 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.springframework.boot.SpringApplicationRunListeners.finished(SpringApplicationRunListeners.java:72) [spring-boot-2.0.0.M3.jar:2.0.0.M3] at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:803) [spring-boot-2.0.0.M3.jar:2.0.0.M3] at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) [spring-boot-2.0.0.M3.jar:2.0.0.M3] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M3.jar:2.0.0.M3] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.M3.jar:2.0.0.M3] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na]

It doesnt start at all but i change to version 1.5.6 and it works fine so i suppose it is 2.0.0M3 problem.

2 Answers2

0

Edit:

M = Milestone build - probably not feature complete; should be vaguely stable (i.e. it's more than just a nightly snapshot) but may still have problems.

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

The problem you are having may very well have to do with the "M" version you are using.

Original answer:

It looks like a conflict between Spring dependency versions. Try using the spring-boot-starter-parent to manage the versions of all of your Spring dependencies:

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

From https://projects.spring.io/spring-boot/:

The recommended way to get started using spring-boot in your project is with a dependency management system –

The parent will allow you to leave out the versions of some dependencies because they will be manage by the management system which will ensure that all dependencies that it is managing are compatible.

So:

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

becomes:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
D.S.
  • 103
  • 8
0

In order to add properly actuator to your project please go to Spring official documentation http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready.

One good approach is to get a ready setup project from https://start.spring.io/ just select actuator and all the dependencies that you need for your project, select the spring boot version and download the project then you can compare your pom.xml with the pom.xml that comes from start.pring.io Also please verify if you are using @SpringBootApplication annotation. hope it help.

Daniel C.
  • 5,418
  • 3
  • 23
  • 26