maven technology (1) software installation and configuration

      In the process of research and development of maven technology, it is very good as a resource dependency management. For example, in the process of Java project development, various jar packages are needed. Under normal circumstances, developers will directly put the jar packages used in the project's lib directory. Next, provide your own program calls. This situation has a very bad disadvantage. Every time we need a jar package, we have to clumsily download it from the Internet, and then copy it to the project, and over time, the capacity of a project will become larger and larger, and in the end we will not be able to. Knowing which jar packages are useful is a waste of resources, not to mention a waste of human time. With maven, everything is much simpler. Maven allows us to put all resource dependencies in the local storage space through the configuration of environment variables and pom.xml, without affecting the project's utilization of resources, and many resources can be Get it directly from the maven repository, which is very convenient and concise.

       Below I will introduce the installation of maven and the configuration of environment variables in the windows environment

 

The first step: go to the official website http://maven.apache.org/download.cgi to download the latest Windows version Binary Zip, the latest version is maven3.2.2, if you are interested, you can also download source research;

 

Step 2: Unzip the downloaded zip to the directory where you want to install maven, such as D:\program files. You can choose the installation directory. There is no requirement for this. After unzipping, all files will be in D:\ program files\ In the apache-maven-3.2.2 directory ;

 

Step 3: Next is the focus of this article - configure environment variables so that we can operate maven in the DOS command line. First, open the system environment variable setting window, add the M2_HOME variable, and the value is the installation directory D:\ program files\ apache-maven-3.2.2. Then add an M2 environment variable, the value is %M2_HOME%\bin, the M2 variable represents the maven running directory, so in order for the system to locate it, the command using this directory must configure M2 into Path. Very simple, just add %M2% to the original Path.

 

Step 4: In this case, we can operate maven on the command line, and finally we can enter mvn -version in dos to check whether the configuration is correct.

 

Note: The resources downloaded from the maven repository are downloaded to ${user.home}/.m2/repository by default. You can define the download directory yourself. You need to change the apache-maven-3.2.2\conf\settings.xml configuration file ,code show as below:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <localRepository>D:\jar\maven_jar</localRepository> <!-- add custom directory here-->

       The above is the installation and configuration of maven. The usage of maven will be explained step by step later. Myeclipse configures maven, pom.xml configuration, and various commands of maven are the key points.

               Disclaimer: This article is original. Please indicate the source and author of the article in the form of hyperlinks for reprinting.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326517237&siteId=291194637