"Maven 3.5" creates Web projects from downloads to using Eclipse _maven

Source: Internet
Author: User
Software Checklist: JDK 1.8 Maven 3.5 Eclipse Java EE IDE for Web developers,version:luna Service Release 2 (4.4.2) Tomcat 8.0 1. The Maven download, unzip, and environment variable settings first ensure that the JDK is already installed in this machine, and configure the environment variable (java_home,path,classpath); go to Maven's website to download the latest version maven:http:// maven.apache.org/download.cgi. Where binary zip/tar.gz archive is a class file, can be used directly, and source Zip/tar.gz archive is a Java file, that is, the source code, can not be used. Windows System downloads apache-maven-3.5.0-bin.zip. As shown in the following illustration:
Extract the MAVEN package to a computer disk, configure the environment variable (maven_home,path), and do not repeat the procedure. Make sure that the MAVEN version matches the JDK version, for example, MAVEN 3.5 requires a version above JDK 1.7 and JDK 1.7; 2. Set JDK version

To prevent the local JDK from being inconsistent with the default JDK version when updating the MAVEN project.
-Open the Conf/settings.xml of the MAVEN installation directory and add between

<profile>     
      <id>jdk-1.8</id>       
      <activation>       
        <activebydefault>true</ activebydefault>       
        <jdk>1.8</jdk>       
      </activation>       
      <properties>       
        < Maven.compiler.source>1.8</maven.compiler.source>       
        <maven.compiler.target>1.8</ Maven.compiler.target>       
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>       
      </properties>  
</profile>
3. Configure MAVEN Warehouse 3.1. Modify the local warehouse open the MAVEN installation directory Conf/settings.xml, add a word between the <settings></settings> tags:
<localrepository>d:\program files\apache-maven-3.5.0\repository</localrepository>
D:\Program Files\apache-maven-3.5.0\repository is the local warehouse path, you can set up, repository folder needs to be built in advance; Copy the modified settings.xml to the local warehouse under repository; open eclipse→windows→preferences→maven→installations, add Maven installation directory ; Eclipse→windows→preferences→maven→user settings, set as follows:
Run cmd, execute @mvn help:system 3.2. Configuring remote Warehouses

After finishing, temporarily refer to: http://www.cnblogs.com/cnblog-long/p/6611383.html 4. Using MAVEN to create a Web project in eclipse

First make sure that Tomcat is installed and configured in this computer. 4.1. Create Maven-archetype-webapp new→other→maven project→next→ Select Maven-archetype-webapp, set the group ID (package structure, such as Com.ls) and artifact Id (project name) configuration Pom.xml compilation information, add Project Plug-ins and dependency packs, etc.:

<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/maven-v4_0_0.xsd" > <modelversion >4.0.0</modelVersion> <groupId>com.ls</groupId> <artifactid>userloadmaven</ Artifactid>//project name, varies from person <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> ; Name>userloadmaven Maven webapp</name> <url>http://maven.apache.org</url> <dependencies
      > <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <depende ncy> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> &L T;version>2.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> &LT;SCOPE&GT;PROVIDED&LT;/SC ope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifa ctid>jstl</artifactid> <version>1.2</version> </dependency> </dependencies&gt
  ;
    <build> <defaultGoal>install</defaultGoal> <finalName>UserLoadMaven</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artif Actid>maven-war-plugin</artifactid> <configuration> &LT;FAILONMISSINGWEBXML&GT;FALSE&L t;/failonmissingwebxml> </configuration> </plugin> <plugin> <g Roupid>org.apache.maven.plugins</groupid> <artifactId>maven-compiler-plugin</artifactId> <version&  
          Gt;3.5</version> <configuration> <source>1.8</source>  
    <target>1.8</target> <encoding>UTF-8</encoding> </configuration>
 </plugin> </plugins> </build> </project>

Pom.xml, even in the annotation <!---->, it is absolutely not possible to have Chinese and Chinese punctuation, otherwise, porm.xml file will error 4.2. Convert the MAVEN project to eclipse Project right-key project name Properties→project Facets and configure accordingly, as shown in the following illustration:

If you check the Dynamic Web module and modify the version number times error: Cannot change version of Project facet Dynamic Web module to 3.1, refer to: http://blog.csdn.net /steveguoshao/article/details/38414145
To resolve. To add a Maven dependency package to this project classpath:
Final Completion form:

And the project structure is:
4.3. Compiling and publishing projects using Maven

Right-click on the "Pom.xml" file in the project and select "Run as Maveninstall" from the pop-up menu to compile and build the project.
During the compilation and build process, you can see the MAVEN compilation process in the console panel, and if the compilation and build succeeds, you can see the word "Build SUCCESS" in the console panel.
In addition, when modifying the related jar package information in the Pom.xml file, some errors may occur because the warehouse does not exist, and there may be some problems with the project compilation. The Maven clean option allows you to clear the compilation and then modify the pom.xml to the correct situation. The "Maven install" is used to compile and build.

Related Article

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.