java - 关闭或停止后重新加载弹簧上下文
问题描述
如何使用不同的系统变量集重新加载 spring 上下文。在下面的场景中,我正在寻找加载 dev1 属性,在使用 dev2 属性重新启动上下文之前初始化 bean。我想聚合具有不同系统变量的初始化 bean 的响应。
System.setProperty("env","dev1");
String configFile = "spring/app_context.xml";
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(configFile);
context.start();
context.close();
System.setProperty("env","dev2");
String configFile = "spring/app_context.xml";
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(configFile);
context.start();
解决方案
context.refresh()
正在工作中 。
推荐阅读
- python - 在 python 中运行多处理时共享内存全局列表
- javascript - 在 JSP 中使用 Java 读取模型属性值
- css - 当浏览器选项卡暂停时,如何防止 CSS 动画暂停
- javascript - 如何从控制器获得成功或失败响应到 laravel 中的 ajax?
- laravel - 自动运行 php artisan ide:models
- git - Bonobo git 服务器与 Teamcity 的集成
- android - 谷歌分析关闭了安卓应用的漏斗
- image-processing - glGetTexImage 返回全黑纹理
- c - 函数中的结构
- java - MockServer 以空的正文意外响应