<!--开发环境--> <beans profile="development"> <util:properties id="config" location="classpath:properties/development/properties"/> </beans>
<!--生产环境--> <beans profile="production"> <util:properties id="config" location="classpath:properties/production/properties"/> </beans>
默认值,可以在web.xml里定义
<context-param> <param-name>spring.profiles.default</param-name> <param-value>production</param-value> </context-param>
当前值,需要看spring.profiles.active值 ------------------------------------------------- 启动参数: java -jar application.jar -Dspring.profiles.active=dev ---------------- 配置文件application.properties: spring.profiles.active=dev ---------------- 测试用例: @ContextConfiguration(locations = { "/applicationContext.xml" }) @ActiveProfiles("test") public class AccountDaoTest extends SpringTxTestCase { } ----------------
参考:https://blog.51cto.com/14254788/2419516
|