Eclipse Configuration Maven Environment notes from zero

Source: Internet
Author: User

Eclipse Configuration Maven Environment notes

Reprint Please specify: http://blog.csdn.net/kisssun0608/

1. Download maven http://maven.apache.org/download.cgi, choose the latest apache-maven-3.3.3-bin.zip;

2. After decompression, put in the designated directory, such as D:\\dep_tools\;

3. Configure the MAVEN environment variables

4. Start with computer Right-click, properties –> advanced system settings –> environment variables in the system variable column, create a new variable name (m2_home) and variable value (D:\dev_tools\apache-maven-3.3.3 ), OK, OK, OK.

5. Verify that the MVN is installed successfully

Shortcut key win+r–> input cmd–> OK

6. Enter Mvn-version in the pop-up input box; the content maven is installed successfully

7. Configure Maven

To modify the default dependency-Package warehouse Location

Maven directory (D:\dev_tools\apache-maven-3.3.3), Conf, settings.xml

Maven default local warehouse location is ${user.home}/.m2/repository, the use of this directory in the file will be more, occupy more and more space. It is generally recommended to change to a different disk directory. The following configuration changes the default local repository to the D:/dev_tools/deplibs.m2/repository directory (this directory structure needs to be created yourself).

And put the settings.xml in the d:/dev_tools/deplibs/.m2/directory.

8. Download the Eclipse Java EE version http://www.eclipse.org/downloads/

Choose a 32-bit or 64-bit version

This version is the latest version of April 2015, has been brought with the M2eclipse plugin

9. Start Eclipse, configure the M2eclipse plugin to associate the MAVEN program

Eclipse menu bar –> window-> Preferences, MAVEN, installations, add->directory–> on the right, select the installation home directory for MAVEN (D : \dev_tools\apache-maven-3.3.3) –> finish, before the associated Maven hook, apply;

Continue to the next step to set up a custom local warehouse location

Click on the right side of user settings, globalsettings and user settings are set to D:\dev_tools\DepLibs\settings.xml, apply and OK to complete the configuration;

10. Create a MAVEN Web project

Menu bar File->new, project, select Maven Item, Mavenproject, next---not selected Create Asimple project,nextàgroupid Select Select Org.apache.maven.archtypes, Artifact Id Maven-archetype-webapp Next


Click Next > Group ID to enter the package name, enter the project name in the artifact ID

–> Click Finish. Eclipse will automatically create a MAVEN project and will download the required packages in the central repository. If the local warehouse location does not have a package, the required packages are downloaded from the Web, and there is a period of waiting for the project to be subsequently configured

11. When the project is created, the default is to create only src/main/resources for us, without Src/main/java,src/test/java and src/test/resources.


Open Project Properties, Java build path, source see Src/main/java and Src/test/java display missing:


Workaround: Open the libraries, modify it to your own JDK (more than 1.7 versions)

Add Src/test/resources yourself

Right-click the project name –> new, Source folder---fill in the folder name: Src/test/resources

12. Set up Project Facets, select version Java 1.7 and Dynamic Web Module 2.3

Right-click Project, Properties–> projectfacets

13. Set the deployment packaging structure as follows, delete the test related directory, click Add two items in the red box

14. You also need to add the Servlet-api dependency package to the problem in Pom.xml adding a dependency package resolution diagram

Add a good package as follows:

After saving the project will automatically go to find and download the nonexistent jar package.

15. Build and deploy the project

Right-click the entire project pom.xml–> Run as->maven install

But there was such a mistake.

Workaround: Menu bar window–> preperences, Java->installed jres, right Select the JRE environment to use, click Edit, and the default Vmarguments fill in-dmaven.multimoduleprojectdirectory= $M 2_home–> finish.

Console output Results:

Will download some dependent packages

This completes the build

16. View the project deployment files that have been generated

17. Because the project is not linked to Tomcat, temporarily place the war package under Tomcat, launch Tomcat and access the war package

18. Configure Tomcat to have the project automatically deployed to Tomcat to run

menu Bar window, preperences->server Runtime Environment, right, click add–> Select Tomcat corresponding version (Apachetomcat v7.0), NE XT, click Browser, choose the location of the Tomcat installation, name anywhere, JRE select you just configured DEFAULTVM arguments that –> finish;

Servers directory appears on the left

19. See if there is a servers tag in the middle, no words. menu bar window, show view, servers

20. Now that the project is deployed to Tomcat, click Start to start Tomcat

21. Accessing in the browser



Although it is simply a display of Hello World, it can be said that the entire process of development of Maven managed projects on Eclipse, built almost from scratch (without a description of the JDK and Tomcat installation process), deepens its understanding and shares the experience with those who need it.

reprint Please specify: http://blog.csdn.net/kisssun0608/



Eclipse Configuration Maven Environment notes from zero

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.