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 implementVehicle
(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
How to Resolve Java.Lang.Noclassdeffounderror: Javax/Xml/Bind/Jaxbexception
How to Create Comma Separated String in Single Quotes from Arraylist of String in Java
Kafka: How to Delete Records from a Topic Using Java API
Adb Cannot Connect to Daemon At Tcp:5037
Password Validate 8 Digits, Contains Upper, Lowercase, and a Special Character
How to Sort Json Object in Java
How to Get Image Height and Width Using Java
How to Acknowledge Current Offset in Spring Kafka for Manual Commit
How to Exclude a Dependency from Parent'S Project in Maven
Create List of Object from Another Using Java 8 Streams
Java H2 In-Memory Database Error: Table Not Found
Round Off a Double While Maintaining the Trailing Zero
How to Exit an Android App Programmatically
How to Get Row Count Using Resultset in Java
Sonarqube: Missing Blame Information for the Following Files
How to Create a Java Code to Check Multiple Question