Activate Profile
- There are two properties provided by spring to determine which profile will be considered active
- spring.profiles.active and spring.profiles.default
- If spring.profiles.active is set with the profile values then it will determine the profile. It will be given priority.
- If spring.profiles.active is not set then the spring.profiles.default value will determine the profile to be active.
- If neighther of them is provided then no bean will be created, which are annotated with the @Profile annotation.
1) Using init parameter in DispatcherServlet
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>spring.profiles.default</param-name>
<param-value>dev</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
2) In context parameter of the wepp application
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>dev</param-value>
</context-param>
3) Set into the Environment Variable
4) JNDI properties
5) Set in JVM system Properties
6) In test cases use @ActiveProfiles("dev") annotation
yes, you can activate multiple profiles at the same time by providing multiple profiles comma separated names.