jar/war/ear文件的區別【zz】

From http://www.51testing.com/?uid-225738-action-viewspace-itemid-212291


經常在我們Java Web項目中看到jar/war/ear這幾種文件類型,它們之間有何不同之處呢?我查了一些資料歸納整理如下:
jar/war/ear三種文件,在文件結構上,三者並沒有什麼不同,它們都採用zip或jar檔案文件壓縮格式。但是它們的使用目的有所區別:
  Jar文件(擴展名爲. Jar)包含Java類的普通庫、資源(resources)、輔助文件 (auxiliary files)等
  War文件(擴展名爲.War)包含全部Web應用程序。在這種情形下,一個Web應用程序被定義爲單獨的 一組文件、類和資源,用戶可以對jar文件進行封裝,並把它作爲小型服務程序(servlet)來訪問。
  Ear文件(擴展名爲.Ear)包含全部企業應用程序。在這種情形下,一個企業應用程序被定義爲多個jar 文件、資源、類和Web應用程序的集合。
  每一種文件(.jar, .war, .ear)只能分別由應用服務器(application servers)、小型服務程序容器(servlet containers)、EJB容器(EJB containers)等進行處理。
  JAR WAR EAR  
  英文 Java   Archive   file ; Web   Archive   file Enterprise   Archive   file  
  jar:包含內容 class、properties文件,是文件封裝的最小單元; war:Servlet、JSP頁面、JSP標記庫、JAR庫文件、HTML/XML文檔和其他公用資源文件,如圖片、音頻文件等;ear:除了包含JAR、WAR以外,還包括EJB組件  
  部署文件 application-client.xml web.xml application.xml  
  級別 小 中 大  
  jar:封裝類    war:封裝web站點    ear:可以封裝ejb  
JAR: Software developers generally use .jar files to distribute Java applications or libraries, in the form. of classes and associated metadata and resources (text, images, etc.) JAR files build on the ZIP file format.
WAR: In computing, a WAR file (which stands for "web application archive" ) is a JAR file used to distribute a collection of JavaServer Pages, servlets, Java classes, XML files, tag libraries and static Web pages (HTML and related files) that together constitute a Web application.
EAR: An Enterprise ARchive, or EAR, is a file format used by Java EE for packaging one or more modules into a single archive so that the deployment of the various modules onto an application server happens simultaneously and coherently. It also contains XML files called deployment descriptors which describe how to deploy the modules. Maven or Ant can be used to build EAR files.
RAR: A Resource Adapter is an archive file format defined in the J2EE Connector Architecture (JCA) specification. A Resource Adapter aRchive (RAR) file is the valid format for deployment of resource adapters on application servers. J2EE RAR files may also be called connectors.

其他概念:
EJB: Enterprise JavaBeans (EJB) is a managed, server-side component architecture for modular construction of enterprise applications. The EJB specification is one of several Java APIs in the Java EE. EJB is a server-side model that encapsulates the business logic of an application.
JavaBean: JavaBeans are reusable software components for Java that can be manipulated visually in a builder tool. Practically, they are classes written in the Java programming language conforming to a particular convention. They are used to encapsulate many objects into a single object (the bean), so that they can be passed around as a single bean object instead of as multiple individual objects. A JavaBean is a Java Object that is serializable, has a nullary constructor, and allows access to properties using getter and setter methods.
Metadata: Metadata is a means to describe the data files.It provides information about a certain item's content, such as: means of creation, purpose of the data, time and date of creation, creator or author of data, placement on a network (electronic form) where the data was created, what standards used (ISO9000), etc.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章