相关疑难解决方法(0)

多个存储库的Maven设置

我在settings.xml中有以下内容

<mirrors>
       <mirror>
          <id>paid-jars</id>
          <name>jars with license</name>
          <url>http://url:8081/nexus/content/repositories/paidjars/</url>
          <mirrorOf>!central</mirrorOf>
      </mirror>
      <mirror>
          <id>Org-central</id>
          <name>mirror of central</name>
          <url>http://url:8081/nexus/content/repositories/central/</url>
          <mirrorOf>central</mirrorOf>
      </mirror>
  </mirrors>
Run Code Online (Sandbox Code Playgroud)

在pom.xml中我有两个罐子

  1. apache-commons.jar(我假设从中心下载)
  2. licensed.jar(我假设从付费罐子下载)

但是当我运行maven clean install它时,它试图从Org-central下载licensed.jar.

如何让它使用付费罐子下载?是否有可能首先进入Org-central,如果失败,它会尝试付费罐子?如果是这样,怎么样?我不想把repo条目放在pom.xml中


将Settings.xml

<?xml version="1.0" encoding="UTF-8"?>    
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <proxies>    
    <proxy>
      <id>Proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>username</username>
      <password>******</password>
      <host>host.url</host>
      <port>8080</port>
      <nonProxyHosts>local.net|internal.com</nonProxyHosts>
    </proxy>
  </proxies>
 <mirrors>
       <mirror>
          <id>paid-jars</id>
          <name>jars with license</name>
          <url>http://url:8081/nexus/content/repositories/paidjars/</url>
          <mirrorOf>!central</mirrorOf>
      </mirror>
      <mirror>
          <id>Org-central</id>
          <name>mirror of central</name>
          <url>http://url:8081/nexus/content/repositories/central/</url>
          <mirrorOf>central</mirrorOf>
      </mirror>
  </mirrors>
  <profiles>
      <profile>
          <id>compiler</id>
          <properties>
              <JAVA_1_7_HOME>C:\Program Files (x86)\Java\jdk1.7.0_51\bin</JAVA_1_7_HOME>
          </properties>
      </profile>
  </profiles>
</settings>
Run Code Online (Sandbox Code Playgroud)

java build repository nexus maven-3

19
推荐指数
4
解决办法
4万
查看次数

Maven正试图从私有存储库安装每个jar

我在S3中有一个私有存储库,用于发布一个库,然后我在另一个项目中使用.

要发布,我有这个设置:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>

    <extensions>
        <extension>
            <groupId>com.allogy.maven.wagon</groupId>
            <artifactId>maven-s3-wagon</artifactId>
            <version>1.1.0</version>
        </extension>
    </extensions>
</build>

<distributionManagement>
    <repository>
        <id>projectx-aws-release</id>
        <name>ProjectX AWS Release Repository</name>
        <url>s3://projectx-support/maven2</url>
    </repository>
    <snapshotRepository>
        <id>projectx-aws-snapshots</id>
        <name>Projectx AWS Snapshot Repository</name>
        <url>s3://projectx-support/maven2</url>
    </snapshotRepository>
</distributionManagement>
Run Code Online (Sandbox Code Playgroud)

然后,在使用该库的应用程序上:

<build>
    ...

    <extensions>
        <extension>
            <groupId>com.allogy.maven.wagon</groupId>
            <artifactId>maven-s3-wagon</artifactId>
            <version>1.1.0</version>
        </extension>
    </extensions>
</build>

<repositories>
    <repository>
        <id>projectX-aws</id>
        <url>s3://projectX-support/maven2</url>
        <releases><enabled>true</enabled></releases>
        <snapshots><enabled>true</enabled></snapshots>
    </repository>
</repositories>
Run Code Online (Sandbox Code Playgroud)

拥有.circleci/settings.xmlS3 repo的凭据:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <servers>
        <server>
            <id>projectx-aws</id>
            <username>....</username>
            <password>....</password>
        </server>
    </servers>
</settings>
Run Code Online (Sandbox Code Playgroud)

当运行mvn --batch-mode --settings …

java amazon-s3 maven

16
推荐指数
1
解决办法
2191
查看次数

Maven存储库查找顺序

我们有一个基于Apache Archiva的内部存储库,我们已经在pom.xml中配置了存储库标记,如下所示.我是否可以假设所有依赖访问都将由内部存储库解析,如果您有权访问它,并且如果内部存储库由于某种原因而关闭,则将由下面列出的其他存储库解析.

<repositories>
        <repository>
            <id>internal</id>
            <name>Internal Repository</name>
            <url>http://192.168.1.2/archiva/repository/internal</url>
        </repository>

        <repository>
            <id>jboss</id>
            <url>https://repository.jboss.org/nexus/content/repositories/releases</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
....
</repositories>
Run Code Online (Sandbox Code Playgroud)

编辑:

我想取消.m2/settings.xml文件.我想在我的pom.xml文件中定义它,这样如果我的存储库管理器是UP并且正在运行,我希望运行时连接到那里,否则它会想要回退到其他存储库.这可能吗?

repository archiva maven-3 maven

6
推荐指数
1
解决办法
5212
查看次数

maven 如何处理多个 &lt;repository&gt; 配置?

我对 maven 越来越习惯了。但是还是有些问题。

我有多个<repository>在我的pom.xml

  • 下载工件时,Maven 将如何处理这些存储库?会按申报顺序搜索吗​​?

  • 除了明确声明的之外,maven 还会检查默认的centralrepohttp://repo.maven.apache.org/maven2/吗?

  • 如果在 中找不到某些东西explicitly configured repo,maven 会回退到默认的中央仓库吗?

  • 使用多个 repos 好不好?我有点担心不一致。

以下是<repositories>我的部分pom.xml

<repositories>
    <repository>
        <id>ibiblio-central-repo</id>
        <layout>default</layout>
        <name>ibiblio-central-repo</name>
        <releases>
            <checksumPolicy>warn</checksumPolicy>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <url>http://maven.ibiblio.org/maven2/</url>
    </repository>

    <repository>
        <id>oschina-central-repo</id>
        <layout>default</layout>
        <name>oschina-central-repo</name>
        <releases>
            <checksumPolicy>warn</checksumPolicy>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <url>http://maven.oschina.net/content/groups/public/</url>
    </repository>

    <repository>
        <id>oschina-central-repo-3rd-party</id>
        <layout>default</layout>
        <name>oschina-central-repo-3rd-party</name>
        <releases>
            <checksumPolicy>warn</checksumPolicy>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <url>http://maven.oschina.net/content/repositories/thirdparty/</url>
    </repository>
</repositories>
Run Code Online (Sandbox Code Playgroud)

maven-3 maven

6
推荐指数
1
解决办法
1万
查看次数

下载依赖仅与 maven 形成特定的存储库

可能的重复:
如何在 Maven settings.xml 中设置存储库的顺序

我正在为一个项目使用一个内部 maven 存储库,当我指定一个依赖项时,我希望 maven 只在内部存储库中而不是在公共存储库中查看这个依赖项。例子:

<repositories>
 ...
 <myrepository...>
 <publicrepo...>
</repositories>

[..]


<dependency>
        <groupId>imygroupid</groupId>
        <artifactId>myartifactId</artifactId>
        <version>1.0-SNAPSHOT</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

如果我构建 maven 项目,我可以看到 maven 尝试myartifactId从我在 pom.xml 文件中指定的所有公共存储库中下载工件。有没有办法指定groupId应该在内部存储库中而不是在其他存储库中找到所有工件?

这将解决构建任务期间的一些性能问题。

maven

5
推荐指数
1
解决办法
7422
查看次数

Maven 多个存储库——maven 究竟如何决定哪个存储库获取哪个工件?

我有一个项目需要从两个不同的存储库中获取工件。甚至 repos 中的工件也相互依赖。例如,我的项目可能依赖于工件 A(在 repo 1 中),后者依赖于工件 B(在 repo 2 中),后者又依赖于工件 C(再次在 repo 1 中)。

我在配置 settings.xml 以使其正常工作时遇到了很多麻烦(例如,mvn 总是尝试转到工件 B 的 repo 1,这是错误的)。任何人都知道这在 maven 中是如何决定的?

java dependencies maven

5
推荐指数
1
解决办法
344
查看次数

settings.xml 中 Maven 存储库的顺序

我有一个settings.xml如下所示: -

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
   <servers>
      <server>
         <id>nReleases</id>
         <username>test</username>
         <password>test123</password>
      </server>
      <server>
         <id>nSnapshots</id>
         <username>test</username>
         <password>test123</password>
      </server>
   </servers>

<profiles>
    <profile>
        <id>space</id>
        <repositories>
           <repository>
                <id>central</id>
                <url>http://repo1.maven.org/maven2</url>
            </repository>
            <repository>
                <id>nReleases</id>
                <name>Releases</name>
                <url>http://someserver/repository/maven-releases/</url>
            </repository>
           <repository>
                <id>nSnapshots</id>
                <name>Snapshots</name>
                <url>http://someserver/repository/maven-snapshots/</url>
            </repository>
        </repositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>space</activeProfile>
</activeProfiles>
</settings>
Run Code Online (Sandbox Code Playgroud)

我希望 maven 先检查repo1.maven.org,然后才查看someserver. 有人可以让我知道这是如何实现的吗?

我正在使用 Maven 3.3.9。

我已经解决了这个问题,并试图改变在配置文件中声明 repos 的顺序,但它没有帮助。

<profile>
    <id>space</id>
    <repositories>   
        <repository>
            <id>nReleases</id>
            <name>Releases</name>
            <url>http://someserver/repository/maven-releases/</url>
        </repository>
        <repository>
            <id>nSnapshots</id>
            <name>Snapshots</name>
            <url>http://someserver/repository/maven-snapshots/</url>
        </repository>
        <repository>
            <id>central</id>
            <url>http://repo1.maven.org/maven2</url>
        </repository>
    </repositories> …
Run Code Online (Sandbox Code Playgroud)

maven

3
推荐指数
1
解决办法
2752
查看次数

标签 统计

maven ×6

java ×3

maven-3 ×3

repository ×2

amazon-s3 ×1

archiva ×1

build ×1

dependencies ×1

nexus ×1