WAR and EAR file format
2011-12-17 11:08
288 查看
看Jenkins的时候,安装运行Jenkins时用的是WAR包,所以我就看看什么是war包。
http://en.wikipedia.org/wiki/WAR_file_format_%28Sun%29
In computing, a WAR file (or Web applicationARchive) is aJAR file used to distribute a collection of JavaServer
Pages, Java Servlets, Javaclasses, XML files, tag libraries and static Web pages (HTML and related files) that togetherconstitute a Web application.
所以Jenkins使用war非常合理,因为Jenkins是一个Web application。而There are special files and directories within a WAR file.
The /WEB-INF directory in the WAR file contains a file named
web.xml which defines the structure of the web application. If the web application is only serving JSP files, the web.xml file is not strictly necessary. If the web application uses
servlets, then the servlet container uses web.xml to ascertain to which servlet a URL request is to be routed. web.xml is also used to define context variables which can be referenced within the servlets and it is used to define environmental dependencies
which the deployer is expected to set up. An example of this is a dependency on a mail session used to send email. The servlet container is responsible for providing this service.
因此web.xml非常重要,下面是例子:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>mypackage.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>
<!--上面就是前面说的:the servlet container uses web.xml to ascertain to which servlet a URL request is to be routed
当用户在URL输入.../HelloServlet时,就知道请求的是servlet HelloServlet,同时背后应执行的java类是mypackage.HelloServlet-->
<resource-ref>
<description>
Resource reference to a factory for javax.mail.Session
instances that may be used for sending electronic mail messages,
preconfigured to connect to the appropriate SMTP server.
</description>
<res-ref-name>mail/Session</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
The /WEB-INF/classes directory is on the ClassLoader's classpath. This is where .class files are loaded from when the web application is executing. Any JAR files placed in the /WEB-INF/lib directory will also be placed on the ClassLoader's classpath.
Advantages of WAR files:
security - no one can modify the deployment, once the war file is signed and deployed
easy development, testing and deployment
the version of the deployed application is easily identified
all J2EE containers support .WAR files
One disadvantage of web deployment using WAR files in very dynamic environments is that minor changes cannot be made during runtime. Any change whatsoever requires regenerating and redeploying the entire WAR file.
总之这个wiki写的很精华,值得一看。
再来看看EAR
http://en.wikipedia.org/wiki/EAR_%28file_format%29
EAR (Enterprise Archive) 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.
Ant or Maven can be used to build EAR files.
An EAR file is a standard JAR file (and therefore a Zip file) with a .ear extension, with one or more entries representing the modules of the application, and a metadata directory called
http://en.wikipedia.org/wiki/WAR_file_format_%28Sun%29
In computing, a WAR file (or Web applicationARchive) is aJAR file used to distribute a collection of JavaServer
Pages, Java Servlets, Javaclasses, XML files, tag libraries and static Web pages (HTML and related files) that togetherconstitute a Web application.
所以Jenkins使用war非常合理,因为Jenkins是一个Web application。而There are special files and directories within a WAR file.
The /WEB-INF directory in the WAR file contains a file named
web.xml which defines the structure of the web application. If the web application is only serving JSP files, the web.xml file is not strictly necessary. If the web application uses
servlets, then the servlet container uses web.xml to ascertain to which servlet a URL request is to be routed. web.xml is also used to define context variables which can be referenced within the servlets and it is used to define environmental dependencies
which the deployer is expected to set up. An example of this is a dependency on a mail session used to send email. The servlet container is responsible for providing this service.
因此web.xml非常重要,下面是例子:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>mypackage.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>
<!--上面就是前面说的:the servlet container uses web.xml to ascertain to which servlet a URL request is to be routed
当用户在URL输入.../HelloServlet时,就知道请求的是servlet HelloServlet,同时背后应执行的java类是mypackage.HelloServlet-->
<resource-ref>
<description>
Resource reference to a factory for javax.mail.Session
instances that may be used for sending electronic mail messages,
preconfigured to connect to the appropriate SMTP server.
</description>
<res-ref-name>mail/Session</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
The /WEB-INF/classes directory is on the ClassLoader's classpath. This is where .class files are loaded from when the web application is executing. Any JAR files placed in the /WEB-INF/lib directory will also be placed on the ClassLoader's classpath.
Advantages of WAR files:
security - no one can modify the deployment, once the war file is signed and deployed
easy development, testing and deployment
the version of the deployed application is easily identified
all J2EE containers support .WAR files
One disadvantage of web deployment using WAR files in very dynamic environments is that minor changes cannot be made during runtime. Any change whatsoever requires regenerating and redeploying the entire WAR file.
总之这个wiki写的很精华,值得一看。
再来看看EAR
http://en.wikipedia.org/wiki/EAR_%28file_format%29
EAR (Enterprise Archive) 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.
Ant or Maven can be used to build EAR files.
An EAR file is a standard JAR file (and therefore a Zip file) with a .ear extension, with one or more entries representing the modules of the application, and a metadata directory called
META-INFwhich contains one or more deployment descriptors.
相关文章推荐
- Visual Studio, Microsoft Portable Executable and Common Object File Format Specification
- Visual Studio, Microsoft Portable Executable and Common Object File Format Specification
- how to create image file and format it
- Converting Image File Format From GHO to VMDK and From VMDK to GHO
- What is the content of J2EE EAR, WAR and JAR files?
- PBM, PGM, PNM, and PPM File Format Summary
- ffmpeg示例一:how to use libavformat and libavcodec to read video from a file.
- Configure file like format of ini and read data from ini file or write data to ini file
- Read Excel File And Format Records
- Spring load properties file and MessageFormat
- .war vs .ear file
- Read and write excel file with format by pandas and xlwt libraries of python
- MYSQL无法启动,出现CAN’T OPEN AND LOCK PRIVILEGE TABLES: INCORRECT FILE FORMAT ‘db’
- open file and format readin
- Linker and Libraries Guide Chapter 7 Object File Format
- Microsoft Office Word、Excel and PowerPoint 2007 file format compatible package
- Microsoft Portable Executable and Common Object File Format Specification
- BMP文件格式详解(BMP file format)
- 待解决问题:“gcc编译:file format not recognized; treating as linker script”
- maven org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 60