Configure Pom. XML for the war package in Maven

Source: Internet
Author: User
Configure Pom. XML in Maven packaged as a war package
(1) complete configuration: This is the complete configuration of servlet, similar to others.

<Project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion> 4.0.0 </modelversion> <groupid> COM. testmy </groupid> <artifactid> testmy </artifactid> <version> 0.0.1-Snapshot </version> <packaging> war </packaging> <dependencies> <dependency> <groupid> J Avax. servlet </groupid> <artifactid> javax. servlet-API </artifactid> <version> 3.0.1 </version> <scope> provided </scope> </dependency> <groupid> javax. servlet. JSP </groupid> <artifactid> JSP-API </artifactid> <version> 2.2 </version> <scope> provided </scope> </dependency> </dependencies> <build> <plugins> <! -- Web. XML is missing and <failonmissingwebxml> is set to true --> <plugin> <groupid> org. apache. maven. plugins </groupid> <artifactid> Maven-war-plugin </artifactid> <version> 2.6 </version> <configuration> <failonmissingwebxml> false </failonmissingwebxml> </configuration> </plugin> <! -- In the project pom. specify the JDK version in XML --> <plugin> <groupid> Org. apache. maven. plugins </groupid> <artifactid> Maven-compiler-plugin </artifactid> <version> 3.1 </version> <configuration> <source> 1.7 </source> <target> 1.7 </Target> </configuration> </plugin> </plugins> </build> </Project>

(2) When an error is reported in the project:Web. XML is missing and <failonmissingwebxml> is set to true
You need to add the following configuration in POM. xml:

  <plugin>    <groupId>org.apache.maven.plugins</groupId>    <artifactId>maven-war-plugin</artifactId>    <version>2.6</version>    <configuration>     <failOnMissingWebXml>false</failOnMissingWebXml>    </configuration>   </plugin>

(3) In the project, specify the JDK version in POM. xml. By default, the JDK version in Maven is 1.5, which does not meet the requirements. In case of any errors, You need to modify the JDK version to use a higher version.
Add the following configurations:

<! -- In the project pom. specify the JDK version in XML --> <plugin> <groupid> Org. apache. maven. plugins </groupid> <artifactid> Maven-compiler-plugin </artifactid> <version> 3.1 </version> <configuration> <source> 1.7 </source> <target> 1.7 </Target> </configuration> </plugin>

After the preceding modification, the package project is a war package.

Configure Pom. XML for the war package in 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.