![](/img/trans.png)
[英]Maven and Spring = Unable to create application context: Unable to locate 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.