Maven learning_what is maven_why use maven_maven installation and configuration

What is maven?

maven is an automated build tool for the java platform.

Why use maven?

At present, we have also learned a lot of technology. In theory, we have supported us to develop many projects, but we will encounter the following problems many times during development:
1. A project is a project.
If a project is very large, it is not suitable for package division. Module, it is best to correspond to one project per module.
2. The jar package in the project needs to be imported manually. The
same jar package must be stored separately for each project. With the help of maven, the jar package can be stored in the maven warehouse for reference, and there is no need to copy it to your own project.
3. The jar package needs to be downloaded by yourself. There are
various ways to download the jar package provided by the optical network of different technologies.
The official website of some technologies is available for download through maven.
With maven, the jar package can be downloaded in a standardized form.
4. Other jars that a jar depends on need to be manually added by us
...
The role of maven:
Imagine that we will create many projects at the same time at work, and each project may reference some common jar packages (dll files in .NET), One way is to make a copy of these dependent jar packages (or dll files) in each project. This is obviously not good. The same file is stored in multiple copies on the hard disk, which takes up too much space, and these dependent jar packages (Or dll file) version is not easy to manage (such as a public jar package, upgrade from 1.0 to 2.0, if all projects that reference this jar package need to be updated, you must modify each project).
The maven warehouse solves these problems very well. It creates a local warehouse on each machine and manages all the jar packages that the maven project depends on on the machine, and these jar packages are uniquely identified by "coordinates" (Note: Coordinates are another important concept, which will be discussed later, here as long as it is simply understood as an identifier that "uniquely identifies the file name and version number of a jar package"), so that all maven projects do not need to be like Copying the jar package to the lib directory as before, the entire maven project looks very refreshing.

maven installation and download

Download maven 3.1.1
first go to the official website http://maven.apache.org/download.cgi to
Insert picture description here
download and decompress: this is the location
Insert picture description here
where I decompressed. Create a new maven repository folder under the same path: MavenRepository
later this folder will be our maven The warehouse is out.
Copy the path , you will use it later, and enter the conf folder: Insert picture description here
open with a text tool:
Insert picture description here
copy the following code, pay attention to change the path to the one you just copied

<localRepository>C:/Users/33033/OneDrive/Idea/IdeaProjects/MavenRepository</localRepository>
<mirror>
  <id>alimaven</id>
  <mirrorOf>central</mirrorOf>
  <name>aliyun maven</name>
  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>

Paste in the position as shown
Insert picture description here

2.1 Configure environment variables

In the system environment variables,
add %MAVEN_HOME%/bin to the MAVEN_HOME path variable to
Insert picture description here
check whether the configuration is correct. Method:
a) Enter the command line (DOS window) mode, enter mvn -version, if there is a response, the installation is complete, indicating that the environment variables are working
Insert picture description here
Note that the jdk environment must be installed first, otherwise the project cannot be compiled normally later.

May your heart be like flowers and trees, and be born in the sun .

Guess you like

Origin blog.csdn.net/nbcsdn/article/details/99689295