Spring 自定义环境配置
来源:互联网 发布:in是什么交流软件 编辑:程序博客网 时间:2024/06/01 18:21
<beans profile="test">.......</beans> <beans profile="production">.......</beans>
1.在用到ApplicationContext的单元测试用例中,用 @ActiveProfiles
@ContextConfiguration(locations = { "/applicationContext.xml" }) @ActiveProfiles("test")
2.在development和functional test启动Jetty前设置系统变量
System.setProperty("spring.profiles.active", "development"); server.start()
3.在web.xml里
<context-param> <param-name>spring.profiles.default</param-name> <param-value>production</param-value> </context-param>
4.在非生产环境,可以用系统变量”spring.profiles.active”进行覆盖
Run As -->Run Configurations -->Environment 设置变量:spring.profiles.active = development
5.采用Spring框架的独立应用程序
GenericXmlApplicationContext ctx=new GenericXmlApplicationContext();ctx.getEnvironment().setActiveProfiles("test");ctx.load("classpath:applicationContext.xml");ctx.refresh();
阅读全文
0 0
- Spring 自定义环境配置
- 自定义Spring配置标签
- spring 加载自定义配置
- Spring Boot-自定义配置
- Spring Boot自定义配置
- 2、spring-boot 工程配置——配置文件详解:自定义属性、随机数、多环境配置等
- spring环境配置实例
- Spring环境配置
- spring的环境配置
- Spring环境配置
- Spring 环境安装配置
- Spring 环境配置
- Spring--环境配置
- Spring多环境配置
- Spring入门---环境配置
- spring 环境配置
- Spring 配置多环境
- spring环境配置
- 二分搜索树的遍历
- Matplotlib简单使用
- 项目与领域选型通史
- MySQL的数据备份和还原
- Android WiFi开发
- Spring 自定义环境配置
- centos卸载rpm包的方法
- python实现80s爬虫+xunsearch使用
- 华为研发工程师编程题2明明的随机数
- spark(11)-Top N(course20)
- 【Mycat】数据库性能提升利器(三)——Mycat实现Mysql主从复制和读写分离
- layerUI api
- matlab基础——Matrices and Arrays
- 如何利用eclipse创建一个java web项目?