2015-07-20 190 views
1

我有一个项目,它有一个名为repo的目录,其中存储了工件。当我用maven构建它时,nexus表示依赖不能解决;当我从maven设置中删除nexus时,它可以找到工件。配置nexus首先从本地存储库查看工作目录

我想让maven在询问nexus之前查看这个目录,或者像那样,这样我就可以在没有每次激活连接的情况下创建它。我怎样才能做到这一点?我目前的Maven的设置(〜/ .m2目录/ settings.xml中):

<settings> 
    <localRepository>/home/a/.m2/repository</localRepository> 

    <mirrors> 
     <mirror> 
      <!--This sends everything else to /public --> 
      <id>nexus</id> 
      <mirrorOf>*</mirrorOf> 
      <!--<url>http://nexus.yourdomain.nl/content/groups/public</url> --> 
      <url>http://localhost:8081/nexus/content/groups/public</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> 
     </profile> 
     <!-- if you want to be able to switch to the defaultprofile profile put this in the active profile --> 
     <profile> 
      <id>defaultprofile</id> 
      <repositories> 
       <repository> 
        <id>maven.default</id> 
        <name>default maven repository</name> 
        <url>http://repo1.maven.org/maven2</url> 
        <snapshots> 
         <enabled>true</enabled> 
        </snapshots> 
       </repository> 
       <repository> 
        <id>maven.snapshot</id> 
        <name>Maven snapshot repository</name> 
        <url>http://people.apache.org/repo/m2-snapshot-repository</url> 
        <snapshots> 
         <enabled>true</enabled> 
        </snapshots> 
       </repository> 
      </repositories> 
     </profile> 
    </profiles> 
    <activeProfiles> 
     <!--make the profile active all the time --> 
     <activeProfile>defaultprofile</activeProfile> 
    </activeProfiles> 
</settings> 
+0

其中'repo'配置命名的本地仓库?我没有在'settings.xml'中看到它。它在'pom.xml'中吗? –

+0

它不在'settings.xml'和'pom.xml'中。 – SonOfSun

回答

3

的Nexus网站上说的*的mirrorOf模式导致的任何存储库的请求重定向到这面镜子和你的单个存储库组,这在示例是公共组。

可以在mirrorOf字段中使用其他模式。可能有价值的设置是使用external:*。这匹配除使用本地主机或基于文件的存储库之外的所有存储库。

external:*而不是*解决了我的问题。

更新

二解决方案: 通过这个选项,以行家的工作太细:

mvn -Dmaven.repo.local=/path/to/repo