官术网_书友最值得收藏!

Understanding POM dependencies

Maven helps manage the third-party libraries in your operating system. In the olden days, you might have had to copy each third-party library into your project manually. This could be a big problem when you had more than one project. Maven avoids this third-party libraries management confusion by keeping all libraries in a central place for each operating system. Regardless of your project count, the third-party libraries will be downloaded to the system only once.

Maven repositories can be found at https://mvnrepository.com/.

Every operating system has their own local Maven repository location:

  • Windows Maven central repository location:
    C:\Users\<username>\.m2\repository\
  • Linux Maven central repository location:
    /home/<username>/.m2/repository
  • MAC Maven central repository location:
    /Users/<username>/.m2/repository

Whenever you add a third-party library to your POM dependency, the specified JAR and related files will be copied into the location \.m2\repository.

We will learn about the Maven dependency structure by looking at one sample. Let's assume that we need to use Log4j version 2.9.1 in our application. In order to use it, we need to add the dependency to our project. We can search the log4j-core dependency from https://mvnrepository.com and copy the dependency into our POM under dependencies.

A sample Maven dependency is as follows:

主站蜘蛛池模板: 乌兰察布市| 大田县| 连山| 汕头市| 汶川县| 广东省| 申扎县| 饶阳县| 临猗县| 阿荣旗| 永济市| 丹阳市| 京山县| 尼玛县| 山西省| 乌拉特后旗| 济南市| 呼和浩特市| 宁城县| 黑河市| 大名县| 杂多县| 城步| 石泉县| 康马县| 河池市| 章丘市| 延吉市| 伊吾县| 渑池县| 陇川县| 洪泽县| 明水县| 乐至县| 法库县| 郓城县| 五寨县| 绥江县| 漳浦县| 大悟县| 香格里拉县|