6

I have configured oauth in my spring boot application and when i try to run my project main class application fails to start stating that:

'A component required a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' that could not be found.

I have referred few similar Stack Overflow questions and answers but still didn't found any solution.

This is the WebSecurityConfiguration class that i added:

@EnableOAuth2Sso
@Configuration
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter{
     @Override
         protected void configure(HttpSecurity http) throws Exception 
{
            http
                    .csrf()
                        .disable()
                    .antMatcher("/**")
                    .authorizeRequests()
                    .antMatchers("/", "/index.html")
                        .permitAll()
                    .anyRequest()
                        .authenticated();
        }


}

These are my pom.xml dependencies:

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-mongodb</artifactId>
    </dependency>
    <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
        <version>1.4.1.RELEASE</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    <version>5.1.5.RELEASE</version>
     </dependency>
     <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>           
    <dependency>
        <groupId>org.springframework.security.oauth</groupId>
        <artifactId>spring-security-oauth2</artifactId>
        <version>2.0.11.RELEASE</version>
    </dependency>


    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-security</artifactId>
        <version>1.1.3.RELEASE</version>
    </dependency>
</dependencies>

This is my main class

@SpringBootApplication
public class Application {

public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
}

@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
    return args -> {

        System.out.println("Let's inspect the beans provided by Spring Boot:");

        String[] beanNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanNames);
        for (String beanName : beanNames) {
            System.out.println(beanName);
        }

    };
}

}

When i try to run main class it gives the following error:

Description:

A component required a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' that could not be found.

Action:

Consider defining a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' in your configuration.
Denis Zavedeev
  • 7,627
  • 4
  • 32
  • 53
felicity
  • 61
  • 1
  • 2
  • Could you provide links to other related answers that didn't help you? – Matthew Jun 01 '19 at 17:01
  • Please check this https://stackoverflow.com/questions/32081578/spring-security-nosuchbeandefinitionexception-no-qualifying-bean-of-type-org – Dmitry Jan 20 '21 at 09:00

0 Answers0