远程存储库

时间:2016-08-23 15:11:28

标签: java maven

在项目的pom.xml中,它具有从远程存储库下载的依赖项。

<parent>
    <groupId>org.jenkins-ci.plugins</groupId>
    <artifactId>plugin</artifactId>
    <version>1.567</version>
</parent>

<repositories>
    <repository>
        <id>repo.jenkins-ci.org</id>
        <url>http://repo.jenkins-ci.org/public/</url>
    </repository>
</repositories>

我理解的是Maven

  1. 在本地存储库中搜索(如果找不到)
  2. 在本地公司nexus存储库中搜索(如果找不到)
  3. 应从远程存储库下载
  4. 当我执行命令mvn test时,它显示如下的跟踪

    在错误中显示它是从本地nexus存储库下载

    Could not find artifact org.jenkins-ci.plugins:plugin:pom:1.567 in nexus (http://localnexus/nexus/content/groups/group/) and 'parent.relativePath' points at no local POM 
    

    任何人都可以帮我解决这个问题.. 它与代理设置有关吗?

    因为它没有进入远程存储库链接..

     D:\Hygieia-master\hygieia-jenkins-plugin>mvn test
    
    [INFO] Scanning for projects…
    
    Downloading: http://localnexus/nexus/content/groups/group/org/jenkins-ci/plugins/plugin/1.567/plugin-1.567.pom
    
    Downloading: http://repo.jenkins-ci.org/public/org/jenkins-ci/plugins/plugin/1.567/plugin-1.567.pom
    
    [ERROR] [ERROR] Some problems were encountered while processing the POMs:
    
    [FATAL] Non-resolvable parent POM for org.jenkins-ci.plugins:hygieia-publisher:1.4-SNAPSHOT: Could not find artifact org.jenkins-ci.plugins:plugin:pom:1.567 in nexus (http://localnexus/nexus/content/groups/group/) and 'parent.relativePath' points at no local POM @ line 15, column 13
     @
    
    [ERROR] The build could not read 1 project -> [Help 1]
    
    [ERROR]
    [ERROR]   The project org.jenkins-ci.plugins:hygieia-publisher:1.4-SNAPSHOT (D:\Hygieia-master\hygieia-jenkins-plugin\pom.xml) has 1 error
    
    [ERROR]     Non-resolvable parent POM for org.jenkins-ci.plugins:hygieia-publisher:1.4-SNAPSHOT: Could not find artifact org.jenkins-ci.plugins:plugin:pom:1.567 in nexus (http://localnexus/nexus/content/groups/group/) and 'parent.relativePath' points at no local POM @ line 15, column 13 -> [Help 2]
    [ERROR]
    
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
    
    [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
    

    以下是我的Settings.xml

      <settings>
        <servers>
            <server>
                <id>nexus</id>
                <username>user</username>
                <password>pwd</password>
                <configuration>
                    <httpConfiguration>
                        <all>
                            <params>
                                <param>
                                    <name>http.authentication.preemptive</name>
                                    <value>%b,true</value>
                                </param>
                            </params>
                        </all>
                    </httpConfiguration>
                    <httpHeaders>
                        <property>
                            <name>username</name>
                            <value>user</value>
                        </property>
                    </httpHeaders>
                </configuration>
            </server>
        </servers>
    
      <mirrors>
        <mirror>
          <!--This sends everything else to /public -->
          <id>nexus</id>
          <mirrorOf>central</mirrorOf>
          <url>http://localnexus/nexus/content/groups/group/</url>
        </mirror>   
      </mirrors>
      <profiles>
        <profile>   
          <id>nexus</id>
          <!--Enable snapshots for the built in central repo to direct -->
          <!--all requests to nexus via the mirror -->
          <repositories>
            <repository>
              <id>central</id>
              <url>http://central</url>
              <releases><enabled>true</enabled></releases>
              <snapshots><enabled>true</enabled></snapshots>
            </repository>
    
          </repositories>
         <pluginRepositories>
            <pluginRepository>
              <id>central</id>
              <url>http://central</url>
              <releases><enabled>true</enabled></releases>
              <snapshots><enabled>true</enabled></snapshots>
            </pluginRepository>
    
          </pluginRepositories>
          <properties>
                  <archetypeCatalog>http://localnexus/nexus/content/groups/PUBLIC_REPO/</archetypeCatalog>
          </properties>
    
        </profile>
      </profiles>
      <activeProfiles>
        <!--make the profile active all the time -->
        <activeProfile>nexus</activeProfile>
      </activeProfiles>
    
    
    
    
    </settings>
    

1 个答案:

答案 0 :(得分:1)

这与此question

类似

如果从远程存储库中获取父pom,则可以将父标记修改为

    <parent>
        <groupId>org.jenkins-ci.plugins</groupId>
        <artifactId>plugin</artifactId>
        <version>1.567</version>
        <relativePath></relativePath>
    </parent>

添加空的相对路径将解析存储库中的父POM。如果未指定relativePath,则默认为../pom.xml。

来自文档,

  

签出中父pom.xml文件的相对路径。如果未指定,则默认为../pom.xml。 Maven首先在文件系统上的这个位置查找父POM,然后是本地存储库,最后在远程仓库中查找。 relativePath允许您选择不同的位置,例如,当您的结构是平的时,或者更深,没有中间父POM。但是,组ID,工件ID和版本仍然是必需的,并且必须与给定位置中的文件匹配,否则它将恢复为POM的存储库。此功能仅用于增强该项目的本地结帐的开发。如果要禁用该功能,请将值设置为空字符串,并始终从存储库中解析父POM。   默认值为:../ pom.xml。

请参阅此处doc