2012-02-17 116 views
5

我有一個運行在websphere應用程序服務器8(WAS)上的web應用程序。在web.xml中我有:在websphere應用程序服務器中彈簧加載資源

<context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>classpath*:by/example/**/*-ctx.xml</param-value> 
</context-param> 

然後當我部署我的應用程序在WAS - 它通過與前綴「wsjar的:文件...」的網址加載我所有的CTX文件是好的。

但是當我工作的程序,我嘗試使用我的應用程序上下文的對象加載資源,這樣的:

applicationContext.getResource("classpath*:by/example/**/I-*.sql").getUrl() 

它拋出URL不正確的例外 - 但如果我添加preffix「wsjar的:」像這:

applicationContext.getResource("wsjar:classpath*:by/example/**/I-*.sql").getUrl() 

它運作良好。但我需要創建通用系統來加載不同的應用程序服務器和servlet容器上的資源。在tomcat前綴不需要。

如何通過ContextLoaderListener以與ContextLoader相同的方式在WAS中加載資源,而無需preffix「wsjar:」加載我的ctx文件?

回答

-1

嘗試類似這樣的事情。

 ApplicationContext appContext = 
     new ClassPathXmlApplicationContext(new String[] {"If-you-have-any.xml"}); 

    Resource resource = 
     appContext.getResource("classpath*:by/example/**/I-*.sql"); 
+2

問題是,「Resource resource = appContext.getResource(」classpath *:by/example/**/I - *。sql「);」不在工作 – 2012-02-17 13:46:29

1

當我使用完整軟件包名稱時,我對IBM WAS沒有任何問題。像這樣:

  classpath:com/tdp/abc/facilitador/boost/config/reglaBoostWS-support.xml   

我沒有嘗試使用星號來指向多個文件。也許列出所有個人文件可以爲你工作。

相關問題