java JavaEE 应用程序中的 app-inf 和 web-inf 文件夹有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12191794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 07:58:12  来源:igfitidea点击:

What difference between app-inf and web-inf folders in JavaEE applications?

javajakarta-eeweb-inf

提问by Ishikawa Yoshi

Can you give me understanding of main difference between APP-INF and WEB-INF folders in javaEE applications.

您能否让我了解 javaEE 应用程序中 APP-INF 和 WEB-INF 文件夹之间的主要区别。

Thanks

谢谢

回答by Sai Ye Yan Naing Aye

APP-INF

应用程序信息

In an enterprise application (EAR application) which contains many war and jars (eg.WebApp1.war, WebApp2.war, EJB1.jar and EJB2.jar.) and suppose all these Modules want to use some classes which is available as part of a Jar (common.jar). So in this case it is better to Place this jar file inside under “APP-INF” directory,that why we don't need to put the same Jar 4 times inside each and every Modules.

在包含许多 war 和 jar(例如 WebApp1.war、WebApp2.war、EJB1.jar 和 EJB2.jar。)的企业应用程序(EAR 应用程序)中,假设所有这些模块都想使用一些作为其一部分可用的类一个罐子(common.jar)。所以在这种情况下,最好将这个 jar 文件放在“APP-INF”目录下,这就是为什么我们不需要在每个模块中放置 4 次相同的 Jar。

WEB-INF

网络信息

WEB-INF is a directory that is a private area of the web application, any files under WEB-INF directory cannot be accessed directly from browser by specifying the URL.

WEB-INF 目录是Web 应用程序的私有区域,WEB-INF 目录下的任何文件都不能通过指定URL 直接从浏览器访问。

See EAR application structure;

参见EAR应用结构;

enter image description here

在此处输入图片说明

回答by Arjan Tijms

Can you give me understanding of main difference between APP-INF and WEB-INF folders in java EE applications.

您能否让我了解 Java EE 应用程序中 APP-INF 和 WEB-INF 文件夹之间的主要区别。

APP-INF is specific for WebLogic. In the Java EE standard it does not exist, hence for Java EE applications there is nothing to compare. Java EE does have an [EAR]/lib directory that takes the place of the non-standard APP-INF/lib. Optionally another directory can be configured in [EAR]/META-INF/application.xml"

APP-INF 特定于 WebLogic。在 Java EE 标准中它不存在,因此对于 Java EE 应用程序没有什么可比较的。Java EE 确实有一个 [EAR]/lib 目录来代替非标准的 APP-INF/lib。可以选择在 [EAR]/META-INF/application.xml 中配置另一个目录”

<application>
   <library-directory>APP-INF/lib</library-directory>
</application>

There is no direct replacement for APP-INF/classes in standard Java EE. You'll have to jar these up as well and put them in [EAR]/lib as well.

标准 Java EE 中没有直接替代 APP-INF/类。您还必须将它们打包并放入 [EAR]/lib 中。