Location>code7788 >text

Beginner's Guide - Newcomers to the job - maven-related

Popularity:718 ℃/2024-09-28 09:58:38

I. Preface

After joining the company, I found out that the company is using Maven to manage and build projects.
In general, start by identifying the following points for yourself:
1. Whether the company has requirements for the version.
2, whether IDEA is required to have a special configuration for maven.
3. Determine whether your MAVEN_HOME system environment is configured.
4. Determine whether the configuration file in maven is changed to the company requirements.

Maven is an open source project under apache , is a tool for managing and building java projects .
Official website:/
Open Source Project:/#projects-list
Central Warehouse:/

II. Common problems and solutions

Q1:The correct coordinates are introduced in the pom file, and the maven install command is executed, but the corresponding dependency is still not found?

A1:

Go to the central repository, find the corresponding dependencies, and download the relevant jar packages and configuration files to the path of the maven repository on your disk.
Central Warehouse Address:/

Maybe the jar package can be downloaded directly by clicking on it, but the configuration file can not be downloaded by clicking on it, after clicking on it, it just opens it, then you can copy all the contents of the configuration file to your own newly created file with the same name as the artifactId in the coordinates of the newly created file.

Q2:After initializing the local repository and automatically importing dependencies, I disconnected in the middle of the process and have been unable to import again?

A2:

Initially, our local repository does not have any jar packages, at this time will go from the private service to download (if there is no configuration, directly from the central repository to download), may be due to network reasons, jar packages are not completely downloaded, these incomplete jar packages are ending with lastUpdated. At this time, maven will not re-download for you, you need to delete these files ending with lastUpdated, then maven will automatically download these jar packages again.
If there are many such files ending with lastUpadted in the local repository, you can define a batch file.

Write the following script in it to delete it:
set REPOSITORY_PATH=E:\develop\apache-maven-3.6.1\mvn_repo
rem Searching for...

del /s /q %REPOSITORY_PATH%*.lastUpdated

rem Search complete.
pause

After writing the above script, put the script file into the local repository directory, for example: D:\apache-maven-3.6.3\repository
Just click Execute.

Continuously updated 。。。。。
Your likes, follows and favorites are what keep me updating!!!!