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

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:

主站蜘蛛池模板: 图木舒克市| 泰和县| 洪湖市| 墨玉县| 莎车县| 永胜县| 宾阳县| 绥棱县| 台南市| 灵川县| 尚义县| 麻江县| 宜兴市| 个旧市| 朝阳市| 邓州市| 双柏县| 平顺县| 福州市| 通江县| 达孜县| 玛纳斯县| 麻城市| 汉中市| 新巴尔虎左旗| 陕西省| 凌云县| 安岳县| 南投县| 洛川县| 巴青县| 洛隆县| 大理市| 马山县| 绥化市| 涞源县| 建水县| 兖州市| 扎鲁特旗| 云林县| 上栗县|