@Conditionalproperty use case

use case1
We want to create only 1 bean, either a MySQL component or a NoSQL component
use case -2
We have 2 components sharing the same codebase, but 1 component needs the MySQL component, and the other needs the NoSQL component
@profile use case
Yes using both we can achieve this requirement but @profile is technically intended for environment separation rather than application specific bean creation
Example Profile
DEV username/pass
QA username/pass
The username and password is just one example there are so many other configuration which are different for different environments like
URL Port number
connection timeout
Request timeout value
Throttle values
Retry values
How to do it ?
We put the configuration in application file but how to handle different environment configuration
application - uat.properties application - dev.properties application - prod.properties
@value
TWO ways we can load dynamically
spring username
application.properties spring.profiles.active=qa
It will be used like parent and child relationship – application.properties = parent application-qa.properties=child
Or///
We can pass the value to this spring configuration || spring profiles.active during application startup itself.
MVN spring-boot:run -Dspring-boot.run.profiles=prod
profiles = prod