为什么在JBoss 5.1中类路径默认为WEB-INF / classes /而不是WEB-INF /? [英] Why does the classpath default to the WEB-INF/classes/ instead of WEB-INF/ in JBoss 5.1?

查看:160
本文介绍了为什么在JBoss 5.1中类路径默认为WEB-INF / classes /而不是WEB-INF /?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一段代码使用

context =  new ClassPathXmlApplicationContext("application-context.xml");

文件位于WAR的 WEB-INF / application-context.xml中
在JBoss 4.2.3中,上述代码可以正常工作。在JBoss 5.1中,经过试验后,似乎期望该文件位于 WEB-INF / classes / application-context.xml中。

The file is located inside the WAR's "WEB-INF/application-context.xml" In JBoss 4.2.3, the above code works fine. In JBoss 5.1, after experimenting, it seems to expect the file to be in "WEB-INF/classes/application-context.xml". And after shifting the file there it works.

我也在Google上四处搜寻,看到了很多有关VFS如何与Spring的类路径或其他东西混淆的参考。

I also googled around saw lots of references to how the VFS messes with Spring's classpath or something..

推荐答案

不应将 WEB-INF 目录本身放在类路径中。如果这在JBoss 4.x上有效,则必须对其进行专门配置。

The WEB-INF directory itself is not supposed to be on the classpath. If that was working on JBoss 4.x, then it must've been specifically configured to do so.

WEB-INF / classes 在标准类路径上是 。这是存放文件的正确位置。

WEB-INF/classes, on the other hand, is on the standard classpath. This is the correct place for the file to go.

JBoss 5.x不会像您建议的那样弄乱Spring。但是,它确实收紧了JBoss 4.x中存在的一些松散行为,这也许就是一个例子。

JBoss 5.x doesn't mess around with Spring in the way that you're suggesting. It did, however, tighten up some loose behaviour present in JBoss 4.x, and this may be an example of this.

这篇关于为什么在JBoss 5.1中类路径默认为WEB-INF / classes /而不是WEB-INF /?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆