Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure Maven

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to install and configure Maven, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

First, installation step 1. download

Official website: http://maven.apache.org/

Download the latest version

Download the historical version

two。 Extract and configure environment variables

Specify the path of the reference type in PATH to make it easy to keep Path invariant (if you switch to multiple versions of Maven, just change MAVEN_HOME, and M2_HOME).

Verify:

Second, view the configuration

Setting.xml files in the conf directory (global configuration files)

1. Ali cloud image configuration: nexus-aliyun *,! the meaning of the value in the Nexus aliyun http://maven.aliyun.com/nexus/content/groups/public2.mirrorOf tag

1. If the value is central, it means that the configuration is the image of the central repository, and any request for the central repository will be directed to this image. Users can also use the same method to configure images of other repositories.

two。 Is an asterisk, indicating that the configuration is a mirror of all Maven repositories, and any requests for remote repositories will be directed to this mirror

3. Indicates that the image matches all remote repositories except jeecg and jeccg-snapshots

Third, use 1. Command mode

The command of Maven should be executed in the directory where pom.xml is located.

Part of this command is quoted from: https://blog.csdn.net/qq_22172133/article/details/81666926

(1) single command

Mvn compile: compilation command, which compiles the source code in the main directory. After execution, there is an additional target folder under hellomaven, and resources such as related jar packages are added in the repository.

Mvn clean: clear commands to clear compiled class files, specifically files in the target directory, including target. The warehouse is not empty.

Mvn test: a test command that compiles the source code in the test and main directories, generates target, and so on. And a .txt file is generated in [target\ surefire-reports] to report the execution (error).

Mvn package: the package command, which packages the program as jar. Under the target directory.

Mvn install: the installation command will install the packed package to the local warehouse. Information such as the generated version number is configured (referenced) by the pom.xml file:

(2) combine commands

Mvn clean compile: clear before compiling

Mvn clean test: emptying before testing

Mvn clean package: execute clean first, then package to package the project, which is usually applied before release

Mvn clean install: execute clean first, then install to package the project, usually before release

Note: when a maven project is packaged into a jar package, the third-party jar is not packaged by default. If you want to package the third-party jar file at the same time, you need to add the following:

Maven-assembly-plugin jar-with-dependencies 2. Use with IDEA

Project structure:

Every time you create a project, check to see if you specify a path for yourself.

These are all the contents of the article "how to install and configure Maven". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report