Reputation: 852
We can import an XML resource in Spring Boot project like this:
@ImportResource("${locationProperty:defaultLocation}")
But I need to import this file according to a condition. Such as, if a property value is false, it shouldn't import this file, it it's true, it should import.
How can I conditionally import a resource in Spring Boot application?
Upvotes: 0
Views: 1881
Reputation: 6936
You can use ConditionalOnProperty
Something like:
@Configuration
@ConditionalOnProperty(prefix = "beans", name = "additional")
@ImportResource("${path-to-bean-config}")
public class AdditionalXmlBeans{
}
Upvotes: 2