关于maven:Maven的仓库分类

12次阅读

共计 1472 个字符,预计需要花费 4 分钟才能阅读完成。

本地仓库

Maven 的本地仓库,在装置 Maven 后并不会创立,它是在第一次执行 maven 命令的时候才被创立。本地仓库地位通过 localRepository 设置:
<localRepository>C:/apache-maven-3.2.5/repository</localRepository>

近程仓库

近程仓库包含:地方仓库、私服。

地方仓库

Maven 地方仓库是由 Maven 社区提供的仓库,其中蕴含了大量罕用的库,无需显示的配置。在 \lib\maven-model-builder-3.2.5.jar\org\apache\maven\model\pom-4.0.0.xml 文件中,能够看到地方仓库的配置。

  <repositories>
    <repository>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
    </pluginRepository>
  </pluginRepositories>

私服

私服是一种非凡的近程仓库,个别用来治理公司外部的 jar 包,公司外部本人开发的公共类库,提供通用的性能,或者提供给其余我的项目依赖应用,这些 jar 包上传到私服,其余我的项目中通过配置依赖能够下载到这些专用的 jar 包。setting 文件中私服的配置:

  <profiles>
        <profile>
            <id>nexus-repo</id>
            <repositories>
                <repository>
                    <id>nexus-public</id>
                    <url>http://localhost:8080/nexus/content/groups/public/</url>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                </repository>
            </repositories>
        </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>nexus-repo</activeProfile>
  </activeProfiles>

通过 profile 配置私服信息,最初激活 profile 配置就能够失常从私服下载 jar 包了。

搜寻程序

  • 在本地仓库中寻找,如果没有则进入下一步。
  • 在全局配置的私服仓库(在 settings.xml 中配置并激活)中寻找,如果没有则进入下一步。
  • 在我的项目本身配置的私服仓库(pom.xml)中寻找,如果没有则进入下一步。
  • 在地方仓库中寻找,如果没有则终止寻找。
正文完
 0