2015-07-20 191 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