spring security: NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.security.config.annotation.ObjectPostProcessor] found

The problem is that you do not have @EnableWebSecurity annotation on your SecurityConfiguration class.

This would have been added by Spring-boot automatically, however since you opted for not using Spring-boot this needs to be taken care of manually.


I use Spring Boot and trigger the same or similar issue with a custom subclass of WebSecurityConfigurerAdapter. I needed to add @EnableWebSecurity to main class to work around the No qualifying bean of type [org.springframework.security.config.annotation.ObjectPostProcessor<?>] exception.


You need add @EnableWebSecurity and @Configuration , the code below is from WebSecurityConfigurerAdapter class, see exception message :

private ObjectPostProcessor<Object> objectPostProcessor = new ObjectPostProcessor<Object>() {
    public <T> T postProcess(T object) {
        throw new IllegalStateException(
                ObjectPostProcessor.class.getName()
                        + " is a required bean. Ensure you have used @EnableWebSecurity and @Configuration");
    }
};