为什么在EAR的lib上使用WEB-INF / lib? [英] Reasons to use WEB-INF/lib over EAR's lib?

查看:115
本文介绍了为什么在EAR的lib上使用WEB-INF / lib?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于正在被视为理所当然的事情,我正在重新考虑。即,在具有以下结构的EAR中:

I am having second thoughts about something I've been taking for granted. Namely, in an EAR with the following structure:

EAR
 \-- boo-ejb.jar
 \-- foo-web.war
 |    \--WEB-INF
 |          \--lib
 \--lib

..我想我理解正确 WEB-INF / lib 仅用于Web应用程序所需的 jars ,而EAR级 lib 仅用于 jars 也是 ejb.jar 所需要的 strong。这样做的理由是使依赖关系更加清晰。但是,为什么不将所有内容都转储到EAR级别的 lib 文件夹中呢?当然,如果有某种冲突,我们希望深入了解和调查。那不是更干净的解决方案,更不容易掩盖潜在的兼容性/依赖性不匹配问题吗?

.. I think I understand correctly that the WEB-INF/lib is for jars needed only by the web application and the EAR-level lib for jars needed by the ejb.jar as well. The rationale being to somehow make the dependencies clearer. However, why not just dump everything in the EAR-level lib folder ? Surely if there is a conflict of some sort we would like to know and investigate in depth. Wouldn't that be a cleaner solution and less prone to covering up a potential compatibility / dependency mismatch problem?

推荐答案

绝对正确-这样会更加清晰明了,并且错误更少,容易导致依赖项不匹配。

You're absolutely right - it would be much clearer and less error prone to dependency mismatch.

但是...

如果您不在EAR中分发Web应用程序怎么办?您将库放置在哪里?

What in cases where you don't distribute your web applications within an EAR? Where would you place the libs? How would you go about distributing your webapps throughout different EARs so you would compose enterprise applications based upon a set of webapps?

WEB-INF / lib也适用于可以仅包含资源(其中没有类)。然后,您是否会将面向Web的资源罐放在EAR级库中?我不这么认为。

WEB-INF/lib is also for jars that can contain resources only (with no classes within). Would you then put the web-oriented resources jars in EAR-level lib? I don't think so.

在EAR的lib上使用WEB-INF / lib也许还有更多的理由,但是以上两种/三种情况应该足以至少说服您重新考虑管理图书馆的策略。

There are perhaps more reasons to use WEB-INF/lib over an EAR's lib, but the above two/three cases should be enough to at least convince you to re-think the strategy to manage libraries.

这篇关于为什么在EAR的lib上使用WEB-INF / lib?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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