本文翻译自:.war vs .ear file

.war和.ear文件有什么区别?


#1楼

参考:https://stackoom.com/question/6gqR/war-vs-ear文件


#2楼

WAR (web archive) files contain servlet class files, JSPs (Java servlet pages), HTML and graphical files, and other supporting files. WAR(Web存档)文件包含servlet类文件,JSP(Java servlet页面),HTML和图形文件以及其他支持文件。

EAR (enterprise archive) files contain the WAR files along with the JAR files containing code. EAR(企业归档)文件包含WAR文件以及包含代码的JAR文件。

There may be other things in those files but their basically meant for what they sound like they mean: WAR for web-type stuff, EAR for enterprise-type stuff (WARs, code, connectors et al). 这些文件中可能还有其他内容,但它们基本上意味着它们的含义:对于Web类型的东西的WAR,对于企业类型的东西的EAR(WAR,代码,连接器等)。


#3楼

From GeekInterview : 来自GeekInterview :

In J2EE application, modules are packaged as EAR, JAR and WAR based on their functionality 在J2EE应用程序中,模块根据其功能打包为EAR,JAR和WAR

JAR: EJB modules which contain enterprise java beans (class files) and EJB deployment descriptor are packed as JAR files with .jar extenstion JAR:包含企业java bean(类文件)和EJB部署描述符的EJB模块打包为带有.jar扩展的JAR文件

WAR: Web modules which contain Servlet class files, JSP Files, supporting files, GIF and HTML files are packaged as JAR file with .war (web archive) extension WAR:包含Servlet类文件,JSP文件,支持文件,GIF和HTML文件的Web模块打包为带有.war(web archive)扩展名的JAR文件

EAR: All above files (.jar and .war) are packaged as JAR file with .ear (enterprise archive) extension and deployed into Application Server. EAR:以上所有文件(.jar和.war)打包为带有.ear(企业归档)扩展名的JAR文件,并部署到Application Server中。


#4楼

war - web archive. 战争 - 网络档案。 It is used to deploy web applications according to the servlet standard. 它用于根据servlet标准部署Web应用程序。 It is a jar file containing a special directory called WEB-INF and several files and directories inside it (web.xml, lib, classes) as well as all the HTML, JSP, images, CSS, JavaScript and other resources of the web application 它是一个jar文件,包含一个名为WEB-INF的特殊目录,其中包含几个文件和目录(web.xml,lib,类)以及Web应用程序的所有HTML,JSP,图像,CSS,JavaScript和其他资源。

ear - enterprise archive. 耳 - 企业档案。 It is used to deploy enterprise application containing EJBs, web applications, and 3rd party libraries. 它用于部署包含EJB,Web应用程序和第三方库的企业应用程序。 It is also a jar file, it has a special directory called APP-INF that contains the application.xml file, and it contains jar and war files. 它也是一个jar文件,它有一个名为APP-INF的特殊目录,其中包含application.xml文件,它包含jar和war文件。


#5楼

A WAR (Web Archive) is a module that gets loaded into a Web container of a Java Application Server . WAR(Web Archive)是一个加载到Java Application ServerWeb容器中的模块。 A Java Application Server has two containers (runtime environments) - one is a Web container and the other is a EJB container. Java Application Server有两个容器(运行时环境) - 一个是Web容器,另一个是EJB容器。

The Web container hosts Web applications based on JSP or the Servlets API - designed specifically for web request handling - so more of a request/response style of distributed computing . Web容器托管基于JSP或Servlets API的Web应用程序 - 专门为Web请求处理而设计 - 因此更多的是分布式计算请求/响应样式 A Web container requires the Web module to be packaged as a WAR file - that is a special JAR file with a web.xml file in the WEB-INF folder. 一个Web容器需要打包为一个WAR文件的Web模块-这是一个特殊的JAR文件web.xml在文件WEB-INF文件夹中。

An EJB container hosts Enterprise java beans based on the EJB API designed to provide extended business functionality such as declarative transactions, declarative method level security and multiprotocol support - so more of an RPC style of distributed computing . EJB容器基于EJB API托管Enterprise Java bean,旨在提供扩展的业务功能,例如声明式事务,声明性方法级安全性和多协议支持 - 因此更多的是RPC风格的分布式计算 EJB containers require EJB modules to be packaged as JAR files - these have an ejb-jar.xml file in the META-INF folder. EJB容器需要将EJB模块打包为JAR文件 - 这些文件在META-INF文件夹中有一个ejb-jar.xml文件。

Enterprise applications may consist of one or more modules that can either be Web modules (packaged as a WAR file), EJB modules (packaged as a JAR file), or both of them. 企业应用程序可能包含一个或多个模块,这些模块可以是Web模块(打包为WAR文件),EJB模块(打包为JAR文件),也可以是两者。 Enterprise applications are packaged as EAR files ― these are special JAR files containing an application.xml file in the META-INF folder. 企业应用程序打包为EAR文件 - 这些是包含META-INF文件夹中的application.xml文件的特殊JAR文件。

Basically, EAR files are a superset containing WAR files and JAR files . 基本上, EAR文件是包含WAR文件JAR文件的超集。 Java Application Servers allow deployment of standalone web modules in a WAR file, though internally, they create EAR files as a wrapper around WAR files. Java应用程序服务器允许在WAR文件中部署独立的Web模块,但在内部,它们创建EAR文件作为WAR文件的包装。 Standalone web containers such as Tomcat and Jetty do not support EAR files ― these are not full-fledged Application servers. Tomcat和Jetty等独立Web容器不支持EAR文件 - 这些文件不是完整的应用程序服务器。 Web applications in these containers are to be deployed as WAR files only. 这些容器中的Web应用程序仅作为WAR文件部署。

In application servers, EAR files contain configurations such as application security role mapping, EJB reference mapping and context root URL mapping of web modules. 在应用程序服务器中,EAR文件包含诸如应用程序安全角色映射,EJB参考映射和Web模块的上下文根URL映射之类的配置。

Apart from Web modules and EJB modules, EAR files can also contain connector modules packaged as RAR files and Client modules packaged as JAR files. 除了Web模块和EJB模块之外,EAR文件还可以包含打包为RAR文件的连接器模块和打包为JAR文件的客户端模块。


#6楼

Ear files provide more options to configure the interaction with the application server. Ear文件提供了更多选项来配置与应用程序服务器的交互。

For example: if the hibernate version of the application server is older than the one provided by your dependencies, you can add the following to ear-deployer-jboss-beans.xml for JBOSS to isolate classloaders and avoid conflicts: 例如:如果应用程序服务器的hibernate版本比依赖项提供的版本旧,则可以将以下内容添加到ear-deployer-jboss-beans.xml中,以便JBOSS隔离类加载器并避免冲突:

<bean name="EARClassLoaderDeployer" class="org.jboss.deployment.EarClassLoaderDeployer">    <property name="isolated">true</property>
</bean>

or to src/main/application/META-INF/jboss-app.xml : 或者到src / main / application / META-INF / jboss-app.xml:

<?xml version="1.0"?>
<jboss-app>
<loader-repository>loader=nameofyourear.ear
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</jboss-app>

This will make sure that there is no classloader conflict between your application and the application server. 这将确保应用程序和应用程序服务器之间不存在类加载器冲突。

Normally the classloader mechanism works like this: 通常,类加载器机制的工作方式如下:

When a class loading request is presented to a class loader, it first asks its parent class loader to fulfill the request. 当类加载请求被呈现给类加载器时,它首先要求其父类加载器来完成请求。 The parent, in turn, asks its parent for the class until the request reaches the top of the hierarchy. 反过来,父级会向其父级询问该类,直到请求到达层次结构的顶部。 If the class loader at the top of the hierarchy cannot fulfill the request, then the child class loader that called it is responsible for loading the class. 如果层次结构顶部的类加载器无法满足请求,则调用它的子类加载器负责加载类。

By isolating the classloaders, your ear classloader will not look in the parent (=JBoss / other AS classloader). 通过隔离类加载器,您的耳朵类加载器将不会查看父类(= JBoss /其他AS类加载器)。 As far is I know, this is not possible with war files. 据我所知,战争档案是不可能的。

.war vs .ear文件相关推荐

  1. eclipse导入jar包_在命令行上操作JAR,WAR和EAR

    eclipse导入jar包 尽管Java IDE和许多图形工具使查看和操作Java归档文件(JAR,WAR和EAR)文件的内容比以往更加容易,但有时我还是更喜欢使用命令行jar命令来完成这些任务. 当 ...

  2. jar 、war、ear_在命令行上操作JAR,WAR和EAR

    jar .war.ear 尽管Java IDE和许多图形工具使查看和操作Java归档文件(JAR,WAR和EAR)文件的内容比以往更加容易,但有时我还是更喜欢使用命令行jar命令来完成这些任务. 当我 ...

  3. 在命令行上操作JAR,WAR和EAR

    尽管Java IDE和许多图形工具使查看和操作Java归档文件(JAR,WAR和EAR)文件的内容比以往更加容易,但有时我还是更喜欢使用命令行jar命令来完成这些任务. 当我必须重复做某事或作为脚本的 ...

  4. ear包目录_Java中的JAR/EAR/WAR包的文件夹结构说明(转)

    JAR包:打成JAR包的代码,一般作为工具类,在项目中,会应用到N多JAR工具包. WAR包:JAVA WEB工程,都是打成WAR包,进行发布,如果我们的服务器选择TOMCAT等轻量级服务器,一般就打 ...

  5. jar 包的认识与处理、jar 文件 war 文件以及 ear 文件

    1. jar 包 将 jar 包解压,其实是该类(.java)编译好的(.class)文件. 包路径 package 多层嵌套的 packages META-INF 文件夹 2. 常用 jar 包及其 ...

  6. java ear war_[转] 基于Java的打包jar、war、ear包的作用与区别详解

    以最终客户的角度来看,JAR文件就是一种封装,他们不需要知道jar文件中有多少个.class文件,每个文件中的功能与作用,同样可以得到他们希望的结果.除jar以外对于J2EE来说还有war和ear.区 ...

  7. java ear和war_JAR、WAR、EAR的使用和区别

    文章摘自:http://blog.csdn.net/lishehe/article/details/41607725  感谢博友分享O(∩_∩)O~ Jar.war.EAR.在文件结构上,三者并没有什 ...

  8. java ear项目_基础普及-Jar、War、Ear

    名词解释 Jar文件(扩展名为. Jar) 包括Java类的普通库.资源(resources).辅助文件 (auxiliary files)等 War文件(扩展名为.War) 包括所有Web应用程序. ...

  9. JAR、WAR、EAR的区别和使用

    最近在回顾EJB,下面对jar,war,ear做以总结. JAR WAR EAR 英文 Java Archive file Web Archive file Enterprise Archive fi ...

最新文章

  1. 谷歌医疗AI再遭重挫!自宫头牌App,副总裁也已离职
  2. Lync日常维护之四:部分管理操作
  3. linux java aptget_apt-get没有安装任何linux服务器
  4. 苹果Xcode帮助文档阅读指南
  5. 本地开发的 SAP UI5 应用,部署到 ABAP 服务器执行出错的问题分析
  6. SAP S/4HANA OData Mock Service 介绍
  7. JAVA标识符中含小数点可以吗_数值类型小数点后是否可以接零问题
  8. hashmap扩容 面试_HashMap面试,看完这一篇就够了(上)
  9. 属于你们的“礼仪小课堂”
  10. 前端学习(3011):vue+element今日头条管理--关于编辑器代码段
  11. c# npoi 2.5版本设置字体加粗_Python帮你做Excel——格式设置与画图
  12. Maven学习总结(57)—— 如何提高 Maven 的构建速度?maven-mvnd 又是什么鬼?
  13. linux系统反应优化,细说Linux系统优化-实践篇【转载】
  14. Flutter 常见问题总结
  15. 每一篇博文都是与自己的一次对话
  16. 第三方支付如何玩转大数据
  17. 一个acmer的感悟
  18. 2021-12-17 每日一练 100元怎么买100个蛋,鸡蛋1毛一个,鸭蛋3元一个,鹅蛋6元一个
  19. 斗破苍穹文字页游php_《斗破苍穹》官方网站! - 页游 - 可以阅读的网页游戏[YeGame.COM]...
  20. 配置云服务器+bt面板搭建自己的服务器

热门文章

  1. CentOS 7安装配置Samba
  2. Eclipse中java文件头注释格式设置
  3. cocoachina上很酷的帖子
  4. 学MFC的九九八十一难
  5. hype-v的磁盘管理(转换)
  6. 如何在Qt Creator中导入图标资源
  7. 【链接】Eclipse的Debug调试技巧
  8. MySQL 数据库基础
  9. pyhton 从web获取json数据 保存到本地然后再读取
  10. CF-697B Barnicle与691C Exponential notation