繁体   English   中英

刷新OSGI Bundle上下文,无法找到Spring NamespaceHandler

[英]Refreshing OSGI Bundle context, Unable to locate Spring NamespaceHandler

我需要在运行时刷新我的应用程序上下文。 为此,我正在执行以下步骤:
1.在我的OSGI包之外创建新的appliction-context.xml
2.使用将旧应用ctx复制到新应用中
InputStream inputStream = new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream("/META-INF/spring/application-context.xml"));
3.刷新应用程序ctx,这意味着切换到新的应用程序ctx,它是在捆绑包ApplicationContext ctx = new FileSystemXmlApplicationContext(newCtxPath); ((ConfigurableApplicationContext)ctx).refresh();之外创建的ApplicationContext ctx = new FileSystemXmlApplicationContext(newCtxPath); ((ConfigurableApplicationContext)ctx).refresh(); ApplicationContext ctx = new FileSystemXmlApplicationContext(newCtxPath); ((ConfigurableApplicationContext)ctx).refresh();

但是我越来越

无法找到用于XML模式名称空间的Spring NamespaceHandler [ http://www.springframework.org/schema/data/mongo]

 http://www.springframework.org/schema/data/mongo

在我的application-context.xml内部,我认为这不是问题,因为在编译过程中,一切正常,当我尝试在运行时刷新ctx时出现问题。

当然,将旧的ctx文件复制到新的文件是成功的,两个文件看起来完全一样。

我找到了更简单的解决方案。

public class CtxRefresher implements ApplicationContextAware {

    private ApplicationContext context;

    public void refreshApplicationCtx(){
        ((ConfigurableApplicationContext)context).refresh();        
    }

    @Override
    public void setApplicationContext(ApplicationContext ctx) throws BeansException {
        context = ctx;      
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM