Spring Security: Nosuchbeandefinitionexception: No Qualifying Bean of Type [Org.Springframework.Security.Config.Annotation.Objectpostprocessor] Found

How to use configuration from spring-security.xml in spring boot?

I would suggest your to please share pom.xml file and also try to use below annotation with springboot application as few things are missing.

depending on your setup, if you get any startup error related to boot autoconfiguration, you might have to exclude some auto-configuration classes, e.g. by putting this onto your Application class:

@EnableAutoConfiguration(exclude = [SecurityFilterAutoConfiguration, SpringBootWebSecurityConfiguration])

also add @EnableWebSecurity annnotation with spring-boot.

No qualifying bean of type [org.springframework.security.config.annotation.web.builders.HttpSecurity] found for dependency

Try removing the @Autowired annotation of the configure(HttpSecurity http) method. The WebSecurityConfigurerAdapter should provide you with the HttpSecurity automatically.

No qualifying Bean found error after adding AOP feature to a Spring project

This behavior is well described in Spring documentation.
Your case is exactly:

If the target object to be proxied implements at least one interface, a JDK dynamic proxy is used.

You can still get the bean by name, and see what is its class:

    Object b = context.getBean("car");      
System.out.println(b.getClass().getName());

It will be something like com.sun.proxy.$Proxy38, and if you try to browse its interfaces, there will be com.AOP.Vehicle among them.

At this point, it is clear why it is impossible to get the bean by class.

What to do ? There are some options:

  • Make Car do not implement Vehicle (any interface). This way, bean will be proxified by CGLIB (and its class remains unchanged), and your code will work
  • Force use CGLIB-proxies everywhere by adding following property to annotation @EnableAspectJAutoProxy(proxyTargetClass=true). Your code will work
  • Get bean by its name (see code above)
  • Get bean(s) by interface:
    Vehicle car =  context.getBean(Vehicle.class);      
car.drive();

Why doesn't the binary search method work if the array is sorted in descending order?

You are trying binary search of a Ascending order sorted array on a Descending order sorted array. Change your method header and method body like this:

int ans = binarySearch(userInput, 0, Size, 10,order);  // order you got from user 

Now this Binary search will work on both Ascending and Descending order of array:

    static int binarySearch(int[] array, int left, int right, int key,int sorting) 
{
if (left > right)
{
return -1;
}

int mid = (left + right) / 2;

if (array[mid] == key)
{
return mid;
}

if(sorting == 2) // if array is sorted in descending order
{
if (array[mid] > key)
{
return binarySearch(array, mid+1, right, key,sorting );
}
return binarySearch(array, left, mid-1, key,sorting );
}
else // if array is sorted in ascnending order
{
if (array[mid] > key)
{
return binarySearch(array, left, mid - 1, key,sorting );
}

return binarySearch(array, mid + 1, right, key,sorting );
}
}


Related Topics



Leave a reply



Submit