Maven Study Notes (2): Maven installation and configuration

Source: Internet
Author: User
Install maven on Windows: 1. First check and install JDK
Run the command echo % java_home % and Java-version through the command line to view the current Java installation folder and Java version number. MAVEN requires that the JDK version number be greater than 1.4.
2. Download MavenGo to the maven download page: Maven. 3. Install MavenDecompress the compressed file to the folder you want to install, for example, my path is: D: \ workspace \ study \ apache-maven-3.2.3. Then create a new variable named m2_home in the system's environment variable and the variable value is the maven installation folder D: \ workspace \ study \ apache-maven-3.2.3. Add % m2_home % \ bin at the end of the system variable path, as shown in figure
The significance of these steps is that when we enter the command in the command line later, Windows will take the initiative to scan the relevant commands in the maven Installation Folder \ bin folder. 4. Check Maven InstallationInput echo % m2_home % and MVN-V to view the maven installation folder and Maven version number.
5. MAVEN updateMaven updates directly decompress the new Maven and change the m2_home user variable to the new installation folder.
Installation Folder analysis: 1. m2_homeIn the folder to which m2_home points, there are the following content:
  • Bin
The folder contains the MVN execution scripts, which are used to configure Java commands, prepare classpath and related Java System attributes, and then execute Java commands. MVN. BAT and mvndebug. Bat are frequently used in windows. What is the relationship between these two files? The two files are basically the same. Only mvndebug has an maven_debug_opts configuration more than maven. Its role is to enable debug when executing Maven to debug Maven itself.
  • Boot
This folder contains only one file, taking my current version number as an example, this file is a plexus-classworlds-2.5.1.jar, plexus-classworlds is a class loader, relative to the default Java class loader, it provides a richer syntax to facilitate configuration. MAVEN uses this loading framework to load its own class libraries. Common users do not need to care about this file.
  • Conf
The folder contains a key file settings. xml. You can directly modify the file to customize Maven behavior on the machine. In general, we prefer to copy the file ~ /. M2/folder (~ Indicates the user folder), and then customizes the maven behavior within the user scope (rather than independent from the maven installation file. Then, we will analyze each element.
  • Lib
This folder includes all the Java class libraries required for Maven execution, Maven itself is developed by modules, so you can see files such as maven-core-3.2.3.jar and maven-model-3.2.3.jar, third-party dependencies used by Maven are also displayed. It can be said that the Lib folder is the real Maven.
2 .~ /. M2Run a simple command: MVN help: System, which prints all Java System attributes and environment variables, the purpose of executing this command is to allow Maven to execute a real task. We can see from the command line output that MAVEN will download Maven-help-plugin, including the POM file and JAR file. These files are downloaded to the maven local repository. Now open the current user folder. In my windows7 folder, It is c: \ Users \ chenlei. CL, which can be seen in this folder. m2 folder. By default, this folder is placed in the maven local repository. m2/Repository. All Maven components are stored in the repository for reuse. Yes ~ In the/. m2/reposi-plugin/org/Apache/Maven/plugins/Maven-help-plugins/folder, find the downloaded Maven-help-plugin pom file and JAR file. Maven determines the location of any component in the repository based on a set of rules (based on the so-called coordinates), which will be detailed in the following sections.
Install m2eclipse: m2eclipse is the next powerful Maven plug-in eclipse. After eclipse is started, select help in the menu, and then select install new software.... Then a install dialog box is displayed. Click work with: addbutton next to the field. A new add repository dialog box is displayed. Enter m2e In the Name field, enter the http://download.eclipse.org/technology/m2e/milestones/1.6 in the location field (it seems that the latest version of eclipse already comes with m2eclipse), and then click okbutton. Eclipse downloads the resources on the m2eclipse installation website. After the resources are loaded, expand all of them to see the interface as shown in.
After selecting the corresponding component, all the way down. Note that some associated components may be downloaded during the download process.
Uninstall m2eclispe:Choose eclipse> help> Installation Details> installed software and select m2eclipse-related components to uninstall them.
Best practices for installing Maven: 1. Set maven_opts Environment VariablesGenerally, the maven_opts value can be set to-xms128m-xms512m. Because the default maximum available memory of Java cannot meet the needs of Maven execution, for example, when the project is large, using Maven to generate a project website requires a large amount of memory. If this configuration is not available, it is very easy to get Java. lang. outofmemeoryerror. Therefore, it is recommended to configure the variable at the beginning. 2. Configure the user scope settings. xmlMaven users can choose to configure $ m2_home/CONF/settings. xml or ~ /. M2/settings. XML, the former is global, and all users on the entire machine will be directly affected by this configuration, while the latter is user range, only the current user is affected by the configuration. Maven will use it first by default ~ /. M2/settings. xml. If it does not exist, $ m2_home/CONF/settings. XML will be used. The user-defined settings are recommended. XML is mainly used to avoid unintentional impact to other users in the system, and to facilitate Maven upgrade in the future, simply copy the configuration file from the repository. 3. Do not use Maven embedded in IDEWhen eclipse is integrated with Maven, an embedded eclipse will be installed. This eclispe is generally newer than idea, but not necessarily very stable. It is often different from the maven version used by the command line. There will be two potential problems here: first, there are many unstable factors in Maven compared with the new version, and easy causes some difficult-to-understand problems. Second, apart from IDE, maven of the command line is also often used. if the version number is inconsistent, easy may cause inconsistency of the build behavior. Therefore, when configuring the maven plug-in the IDE, use Maven that is consistent with the command line. In the m2clipse environment, click windows in the menu bar, and select preferences. In the displayed dialog box, expand the maven item on the left, select the installation item, and in the panel on the right, you can see that the default embedded Maven installation is selected. Click Add... button, select the maven installation folder m2_home, and select this external Maven.


Maven Study Notes (2): Maven installation and configuration

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.