Maven notes (5)-Eclipse and Maven Integration

Source: Internet
Author: User

The eclipse version is 4.2 Juno. Open eclipse and choose help> install new software... open the software installation window and go to work... in the input box, click Add... in the pop-up window name enter: m2eclipse, location input: http://m2eclipse.sonatype.org/sites/m2e.

After the installation is complete, you will be prompted to restart eclipse and restart it. (If you access the Internet through a proxy, you need to set the eclipse proxy first)

After you restart eclipse, specify Maven as the maven you have installed.

 

1. Create a Java Project

1) file ---> New ---> other ---> Maven projet

2) Select Maven-Archetype-Quickstart.

3) enter project information

 

4) The generated Java project package structure is as follows:

 

5) Modify Pom. XML to specify the JDK version at compilation.

 

 <  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  > CN. luxh. app </  Groupid  >    < Artifactid  > My-app </  Artifactid  >    <  Version  > 0.0.1-Snapshot </  Version  >    <  Packaging  > Jar </  Packaging >    <  Name  > My-app </  Name  >    <  URL  > Http://maven.apache.org </  URL  >    <! --  Attribute  -->   <  Properties  >        <  JUnit. Version  > 4.10 </  JUnit. Version  >      <  Project. Build. sourceencoding  > UTF-8 </  Project. Build. sourceencoding  >        < JDK. Version  > 1.6 </  JDK. Version  >    </  Properties  >    <  Build  >        <  Plugins  >            <! --  Specifies the JDK compilation version.  -->           <  Plugin  >                <  Groupid  > Org. Apache. Maven. plugins </  Groupid  >                <  Artifactid  > Maven-compiler-plugin </  Artifactid  >                < Version  > 2.5.1 </  Version  >                <  Configuration  >                    <  Source  > $ {JDK. Version} </  Source  >                    <  Target > $ {JDK. Version} </  Target  >                    <  Showwarnings  > True </  Showwarnings  >                </  Configuration  >            </  Plugin  >       </  Plugins  >    </  Build  >    <  Dependencies  >      <  Dependency  >        <  Groupid  > JUnit </  Groupid >        <  Artifactid  > JUnit </  Artifactid  >        <  Version  > $ {JUnit. Version} </  Version  >        <  Scope  > Test</  Scope  >      </  Dependency  >    </  Dependencies  >  </  Project  > 

 

 

2. Create a WEB Project

1) file ---> New ---> other ---> Maven projet

2) Select Maven-Archetype-webapp

 

3) Fill in the project information

 

4) production Web project package structure

 

 

 

4.1) convert the project to dynamic web module, right-click the project, select Properties, select project facets, and click convert to faceted form...

Select dynamic web module and select 3.0 to support servlet3.0.

Select Java and JDK 1.6 or later.

4.2) the tool generates only one source folder named src/main/resource, we need to manually add src/main/Java, src/test/Java and src/test/resource three source folder, right-click the Project New ----> source folder, enter the folder name.

 

4.3) modify the source folder compilation path, enter the Java build bath window, double-click the Output Folder under each folder, and specify the path.

Src/main/Java and src/main/resource Specify target/calsses, src/test/Java and src/test/resource Specify target/test-classes

Select allow output folders for source folders.

4.4) configure and deployProgramDeployment Assembly: Delete the two items of test. This is not required when the test program is released. Add the maven dependency library and release it to the lib directory during release, add/src/main/webapp as the root directory for deployment

5) Configure Tomcat 7 and release the running project

 

 

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.