Profiles allow us to do different configurations based on different env.
application.yml:
spring: profiles: dev server: port: 8000 --- spring: profiles: test server: port: 9000
We set 'dev' env to run on port 8000, but test env is on port 9000.
Build:
mvn clean package
Then run:
java -jar -Dspring.profiles.active=dev target/xxxx.jar
You will see that port is 8000.
If you run:
java -jar -Dspring.profiles.active=test target/xxxx.jar
Then it will be 9000.
Real world usecases:
1. Third-party dependencies
2. LogLevel cahgnes
3. Service deployments
4. Internal resource deployments