Before running an application supporting different profiles, you will need to select the desired profile to use the configuration needed. A profile can be selected using the spring.profiles.active flag using the JVM parameter, as follows:
$ java -Dspring.profiles.active=dev -jar target/infra-as-code-0.0.1-SNAPSHOT.jar
Finally, you can check the application in the browser using the port associated with the profile provided. Valid values for the spring.profiles.active flag are as follows:
- dev
- production
- test
If you don't provide any value for the flag, then the configurations from application.properties will be used.
Additionally, as we saw in Chapter 10, Containerizing Your Applications, we are able to dockerize a Spring Boot application, and with this knowledge, we can learn about immutable servers and how to test infrastructure changes.
In this section, we are going to learn a similar way to recreate the infrastructure using Vagrant (https://www.vagrantup.com/) version 1.7.0 or later. This may require virtualization software (for example, VirtualBox: https://www.virtualbox.org/).