Differences jar package and war package

The general project is divided into two layers: the service layer and the presentation layer (view level), we usually put the service layer packaged into jar, and put the bag labeled as war of the view layer packages.

 

Careful comparison can be found:

jar package includes all of the services or third-party libraries you write a program, as it is usually behind the scenes, for the view layer to exchange a user's data processing service, the jar file format as a Zip file format as the basis, and Zip is different, it can be released, but also for deployment, which encapsulates the library components and plug-ins, and can be compiled and used jvm, in the jar also contains special file, and deployment of such mainfests application description, for indicating how to handle a particular tool jar.

war file can be viewed as a web application. Jar and is different from the package: it cohesive many pages, such as html, jsp, Servlet, js, css, icon image files, etc., of course, the composition further comprises other components of the web application, these documents do not substantially complex business logic processing portal, basically only used as a program responsible for the user to interact with it.

The advantage of this is:

First, doing so structured hierarchical code, isolated front and rear ends;

Second, easy to draw the front and rear ends of responsibility, speed the development process and help maintain;

Third, it is to rely on post-maintenance projects, such as business complex project but trivial, if only to change the style of the front or adjusted, I also do not have to turn off the service, just stopped web, done modification can be deployed immediately on-line, written for the project, the direct call interface to return to the results can be displayed need only be called according to the page, and the server-side code that does not need change, a great convenience development. (After using springboot, items will be packaged into jar, or may be packaged into a war deployed in an external container)

From the inside:

Directory Structure war package includes the WEB-INF, and war is a web modules can be run directly after doing a web project, you need to deploy packaged in a container, generally placed in the \ directory under the tomcat \ webapps, when start when tomcat, this package will be extracted, which is equivalent released.

The jar generally are more class files, declares Main_cass after the java command can be used to run it.

All packages are hit with a jar, but the extension of the target file is not the same. And similar jar, war is also an archive of many files. This package files according to a certain directory structure to organize: typically it contains the root directory have said before Html and Jsp file or directory that contains these two files, while there will be a WEB-INF directory, usually WEB- INF directory has a file and a web.xml classes directory, web.xml is the application configuration file, the directory contains the classes other classes compiled Servlet class and Jsp or Servlet rely (e.g. JavaBean). Typically these rely on packaged into classes may be put under the JAR directory under lib WEB-INF, of course, you can put the system CLASSPATH, but inconvenient as migration and management.

So the project packaged under what circumstances the use of war, under what circumstances it is clear that the use of the jar.

 



 

Guess you like

Origin www.cnblogs.com/nhdlb/p/11707278.html