Spring profiles is similar to MAVEN profiles, but spring profiles is a configuration file that is selected at the time of deployment, and MAVEN profiles chooses the active profile when it is packaged, and the other files are not included. The two approaches provide great convenience for deployment in different environments: for example, development environment, test environment, production environment, not always modify the configuration files, such as jdbc.properties, and sometimes forget, there is a big problem.
Now SRC (i.e. under the Classpath path) has: Jdbc_dev.properties/jdbc_test.properties/jdbc_production.properties three files, in the development environment, the test environment, Environment variables are configured in the production environment: Spring.profiles.active=dev, Spring.profiles.active=test, spring.profiles.active=production, they are one by one corresponding.
In spring's XML configuration file, you can load the JDBC properties file in the following way
<context:property-placeholder location= "Classpath:jdbc_${spring.profiles.active}.properties"/>
This is the recommended practice by setting environment variables. Another way is to configure it in Tomcat:
Add a property configuration to the%tomcat_home%/conf/catalina.properties file, such as the development environment is Spring.profiles.active=dev
Summary: This allows spring to read the corresponding configuration file in the appropriate environment by configuring it as above.
Spring Profiles in Spring 3.1