While working on a legacy project, sometimes it becomes so hard to find such small pieces of stuff. Recently I faced a similar problem where I had to load spring beans based on the loaded profiles respectively.
With Spring Boot and annotation, it has become really easy. Just put the
@Profile("profile1, profile2") and it works. Similarly, it is done in XML as well. All you need is a bit of knowledge to do so.
So, if you have an XML with application-beans and you want to load different beans based on different profiles then simply wrap the beans under
Here’s the example of the same:
I hope I’ve considered a correct example as it displays the beans loaded by default, loaded based on different profiles.
Let me know in the comments below.