小编Pav*_*nko的帖子

在Springsphere应用程序服务器中按Spring加载资源

我有一个在websphere应用服务器8(WAS)上运行的Web应用程序.在web.xml中我有:

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:by/example/**/*-ctx.xml</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)

然后当我在WAS上部署我的应用程序时 - 它通过带有前缀"wsjar:file ..."的网址加载我的所有ctx文件,这很好.

但是当我在我的工作应用程序中时,我尝试使用我的应用程序上下文的对象来加载这样的资源:

applicationContext.getResource("classpath*:by/example/**/I-*.sql").getUrl()
Run Code Online (Sandbox Code Playgroud)

它抛出了url不正确的异常 - 但如果我添加预加"wsjar:",就像这样:

 applicationContext.getResource("wsjar:classpath*:by/example/**/I-*.sql").getUrl()
Run Code Online (Sandbox Code Playgroud)

它运作良好.但我需要创建通用系统来在不同的应用服务器和servlet容器上加载资源.在tomcat前缀不需要.

如何通过ContextLoaderListener以与ContextLoader相同的方式在WAS上加载我的应用程序中的资源加载我的ctx文件而不预加"wsjar:"?

java websphere spring

6
推荐指数
1
解决办法
1419
查看次数

标签 统计

java ×1

spring ×1

websphere ×1