【问题标题】:Reloading spring context after close or stop关闭或停止后重新加载弹簧上下文
【发布时间】:2018-08-10 11:13:57
【问题描述】:

如何使用不同的系统变量集重新加载 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();

【问题讨论】:

标签: java spring


【解决方案1】:
context.refresh()

正在工作。

【讨论】:

    猜你喜欢
    • 2020-01-10
    • 2021-05-28
    • 2013-09-20
    • 2018-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-10
    • 1970-01-01
    相关资源
    最近更新 更多