Project Catalogue Java/web/maven

Source: Internet
Author: User

The difference between a jar package and a war package

The war is a Web module that needs to include Web-inf, which is a Web module that can be run directly. The jar typically includes only some class files that can be run with the Java command after declaring the Main_class.
They are all compressed packages, with Tomcat, to put the war file package in its \webapps\ directory, start Tomcat, this package can be extracted automatically, that is, your web directory, the equivalent of publishing.
War package: is a Web application, usually a Web site, into a package deployed into a container.
Jar Package: Typically, a generic class is referenced at development time, and a package facilitates storage management.
Ear Package: An enterprise application, typically an EJB that is called an ear package.
All packages are hit with jars, except that the target file has a different extension.

The war package hierarchy of the Java EE

The war is a Web application format presented by Sun, similar to a jar and a compressed package for many files. The files in this package are organized according to a certain directory structure: usually the root directory contains HTML and JSP files or directories containing both files, there will also be a web-inf directory, this directory is very important. Typically there is a Web. xml file and a classes directory under the Web-inf directory, Web. XML is the application's configuration file, while the classes directory contains the compiled servlet class and other classes that the JSP or servlet relies on (such as JavaBean). Often these dependent classes can also be packaged into a jar into the Web-inf under the Lib directory, of course, can also be placed in the system's classpath, but it is not easy to transplant and management. All of the above files form a Web The module (the smallest deployable unit) can be deployed directly, but is typically packaged as a *.war file, which is portable as long as the application server compatible with the Java servlet specification is available.

The WAR (Web archivefile) network application file is a platform-independent file format that allows many files to be combined into a single compressed file.

War Package standard directory structure:

1, index.jsp[Optional]

2, Metainf[maven automatic generation directory]

3. web-inf[must be included]

①classes directory: storing Java class files

②lib directory: Required jar Packages

③web.xml:war's description file

4. subdirectories[Optional Catalogue]

Store some Web pages and photos, such as: Html,jsp,js,jpg and so on.

Maven Project

Maven is now a popular building automation tool that provides lifecycle management throughout the software build process.

The underlying directory structure is as follows:

    • Root directory: Store pom.xml and all subdirectories
    • ${basedir}/src/main/java:java Source Code
    • ${basedir}/src/main/resources: Resource files, such as properties files, configuration files
    • ${basedir}/src/test/java: Unit Test code
    • ${basedir}/src/test/resources: Testing Resources

The jar file is generated by default after compiling the package, and the generated classes file is placed under ${basedir}/target/classes, and the jar file is placed under ${basedir}/target.

For MAVEN projects that are imported directly from Git into eclipse, you usually need to right-click Maven->update projects to update the project hierarchy, or you will report a compilation error.

Project Catalog Java/web/maven

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.