Maven-notes 1 What is Maven and how to install it.

PS: This article is a piece of notes copied together, you can go directly to the reference article.
Push your hub weakly

Maven - notes 1

[Background] Suppose we develop a project or make a small demo. If we use..., then we have to find out the jar packages that we depend on one by one and import them manually. This process will be cumbersome to imagine.

Maven is a software project management tool based on the project object model (POM, project object model ), which can manage the construction, reporting and documentation of the project through a small piece of description information (configuration) .

main effect:

  • Choose to obtain the (specific version) jar package.

  • Find dependencies, download dependencies.

  • Hot deployment, hot compilation. (Reduction of server restart / redeployment)

Directory Structure

Common simple structure

┬ /.settings
├ /src
│ ├ /main
│ └ /test
├ /target
│ └ /class
├ .classpath
├ .project
└ pom.xml
Path/file The main purpose
/src Mainly store source code files, in which there are generally two file directories;
/src/main Put the code used to run the project, and the next level of directories are various packages.
/src/test Put the code used in the test project, and all have resource resource files.
/target Put the compiled code.
pom.xml Resource files, determine the coordinates of which jar packages need to be used by the project, and automatically download them in the central warehouse through the coordinates.

Tips: So how is pom.xml roughly done?

<dependencies>
<dependency>
   <groupId>org.mybatis</groupId>
   <artifactId>mybatis</artifactId>
   <version>3.2.5</version>
</dependency>
</dependencies>

By identifying a Maven project with three elements, the IDE can download it from the remote warehouse.

Installation and configuration

Win10

Prerequisite: It is recommended to install the JDK first.

  • Visit the official website
  • Find download
  • Choose the right file (win10 should choose bin.zip, right?)
  • View the official guide
  • Unzip to a suitable path
  • Add the absolute path of the bin directory to the system environment variable PATH
  • Enter the command line to mvn -vsee the version information returned.

IDEA

???

Directory Structure

┬ /bin
├ /boot
├ /conf
│ ├ /logging
│ ├ settings.xml
│ └ toolchains.xml
├ /lib
├ LICENCE
├ NOTICE 
└ README.txt
Path/file The main purpose
/bin There are two types of Maven startup files: one is to start directly, and the other is to start in debug mode.
/boot Put the class loader framework.
/conf Put the global configuration file setting.xml, which is the configuration implemented by all warehouses. The warehouse also has settings for private configuration. Private configuration is generally recommended because the global configuration is in the Maven installation directory.
/lib Put various jar packages needed for Maven operation.
LICENCE Maven software license
NOTICE Third-party software included in Maven
README.txt A brief introduction to Maven and installation instructions

Solve download-mirror

Because of well-known reasons, it is generally difficult to download things with Maven in China.

Now you usually add the image of Alibaba Cloud in setting.xmlthe <mirrors>tab.

<mirror>
    <id>alimaven</id>
    <mirrorOf>central</mirrorOf>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>

Solve download-proxy

Generally, people want to use tools to download things in official warehouses, or use them only when they have special task requirements.

The premise of being able to proxy is that you have repol.maven.orgaccess to a proxy server that can be pinged .

<proxy>
	<id>optional</id>    //代理Id
	<active>true</active>   //是否要激活
	<protocol>http</protocol>  //采用协议
	<username>proxyuser</username>   //如果代理需要认证就需要账号密码
 	<password>proxypass</password>
    <host>proxy.host.net</host>  // ip
	<port>80</port>   //端口
	<nonProxyHosts>local.net|some.host.com</nonProxyHosts>  
    //不需要代理的主机ip用户|隔开,例如里面的some.host.com,即所有对这个网站的访问都不需要代理

</proxy>

reference

[Long] Maven from entry to master

[Long] maven (1) What is maven~

[中] What is Maven?

[Short/Attached Book] What is the role of Maven?

[E-book/Registration] Maven combat

Guess you like

Origin blog.csdn.net/Tighway/article/details/102195244