代码之家  ›  专栏  ›  技术社区  ›  cetnar

如何手动禁用/黑名单Maven存储库

  •  20
  • cetnar  · 技术社区  · 16 年前


    这是我的基础项目,在我的其他项目中用作依赖项,因此我需要再次等待超时。

    笔记:
    1.为什么搜索Jasper存储库,可能是因为范围

    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>[2.1,)</version>
        <scope>compile</scope>
    </dependency>
    


    3.我使用jasperreports 1.3.3版本,我不想更改它。

    4 回复  |  直到 16 年前
        1
  •  23
  •   Seth Tisue    10 年前

        <repository>
            <id>repo1.maven</id>
            <url>http://repo1.maven.org</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    
        2
  •  13
  •   JasonMArcher TWE    12 年前

    您可以通过在settings.xml中使用mirrorOf声明来覆盖回购。尽管这不是它通常的目的,但在jasper reports repoid上设置一个镜像并将其指向Central(repo1.maven.org)将有效地使其消失。

    更好的选择是使用存储库管理器,如 Nexus 然后您可以控制实际提供的代理和工件。

        3
  •  10
  •   Pascal Thivent    16 年前

    据我所知,这是不可能的。

    为什么它要在Jasper存储库中搜索,可能是因为范围

    是的,我认为范围对这种行为负有“责任”。如果没有范围,Maven就不必检查远程存储库是否有比本地repo中可用版本更新的版本。

    我解决这个问题的想法是更改jasper pom并使用代理存储库,但我正在寻找另一种选择。

    修复jasper pom并使用代理存储库当然是理想的解决方案,但这并不总是可能的。不过,也许有一个解决办法。您是否尝试排除jasperreports的具有范围的可传递依赖项,并在pom中自己提供它们(具有固定版本)。大概是这样的:

    <dependencies>
      <dependency>
        <groupId>jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>1.3.3</version>
        <!-- Remove Transitive dependencies drawn by Jasper Report that we don't want -->
        <exclusions>
          <exclusion>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
          </exclusion>
          ...
        </exclusions>
      </dependency>
      <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>2.1</version><!-- Or whatever version, as long as it's fixed -->
        <scope>compile</scope>
      </dependency>
      ....
    <dependencies>
    

    这样,Maven就不必检查不存在的存储库,也不必等待超时。我想试试。

    我使用jasperreports 1.3.3版本,我不想更改它。

    没问题。