A wee spring-profile example
Present a lightning talk about Spring Profiles
- Java JDK version 8 or later
./gradlew bootRunWe have define 3 profiles: dev, prod, default
To use a profile you must define the environment property spring.profiles.active in any of the usual ways (see the docs)
-
You can include
spring.profiles.active=devon yourapplication.properties, OR -
on command line using the switch
--spring.profiles.active=devOR -
set the environment variable
SPRING_PROFILES_ACTIVE=devon your terminal
If no profile is defined spring uses the default
Using the third option you can run the different profiles with:
SPRING_PROFILES_ACTIVE=dev ./gradlew bootRun
SPRING_PROFILES_ACTIVE=prod ./gradlew bootRun
SPRING_PROFILES_ACTIVE=default ./gradlew bootRun
./gradlew bootRun # default profileCopyright © 2017 Anderson Queiroz
Distributed under the GNU General Public License either version 3.0 or any later version.