你如何阻止 maven 尝试访问 http://repo.maven.apache.org? [英] How do you stop maven from trying to access http://repo.maven.apache.org?

查看:48
本文介绍了你如何阻止 maven 尝试访问 http://repo.maven.apache.org?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

开发机无法上网,60s左右超时.当我尝试构建时,我看到

The development machine cannot access the internet, and take about 60s to timeout. When I try to build, I see

Downloading: http://repo.maven.apache.org/maven2/com/google/gsa-connector/2.8.0/gsa-connector-2.8.0.pom

但是,我的 POM 中有以下内容:

However, I have the following in my POM:

    <repository>
      <id>bb-nexus</id>
      <url>http://repo.dev.bloomberg.com/content/groups/public</url>
      <releases><enabled>true</enabled></releases>
      <snapshots><enabled>true</enabled></snapshots>
    </repository>
    <repository>
      <id>nexus-3rdparty</id>
      <url>http://repo.dev.bloomberg.com/content/repositories/thirdparty/</url>
      <releases><enabled>true</enabled></releases>
      <snapshots><enabled>true</enabled></snapshots>
    </repository>

它总是先尝试去 repo.maven.我什至尝试添加到 D:.m2settings.xml

It always tries to go to repo.maven first. I even tried to add to D:.m2settings.xml

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://repo.dev.bloomberg.com/content/groups/public</url>
    </mirror>
  </mirrors>

基于 http://maven.apache.org/guides/mini/guide-mirror-settings.html 但它继续首先尝试 repo.maven.我正在使用 Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500)

based on http://maven.apache.org/guides/mini/guide-mirror-settings.html yet it continues to try repo.maven first. I'm using Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500)

我不能使用 -o 因为它仍然需要访问本地 repo.dev.

I can't use -o because it still needs to access the local repo.dev.

这里是有效设置":

D:UserschloeProjects	eamconfluence-plugin>mvn help:effective-settings
[INFO] Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins:maven-install-plugin/maven-metadata.xml from/to central (
http://repo.maven.apache.org/maven2): Connection to http://repo.maven.apache.org refused
...
[INFO]
[INFO] --- maven-help-plugin:2.1.1:effective-settings (default-cli) @ bb-confluence-plugin ---
[INFO]
Effective user-specific configuration settings:

<?xml version="1.0" encoding="UTF-8"?>
...
<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoca
tion="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
  <localRepository xmlns="http://maven.apache.org/SETTINGS/1.1.0">d:.m2
epository</localRepository>
  <pluginGroups xmlns="http://maven.apache.org/SETTINGS/1.1.0">
    <pluginGroup>org.apache.maven.plugins</pluginGroup>
    <pluginGroup>org.codehaus.mojo</pluginGroup>
  </pluginGroups>
</settings>

[INFO] ------------------------------------------------------------------------

推荐答案

所有 pom 文件都继承自 maven 超级 POMhttp://maven.apache.org/ref/3.0.4/maven-model-builder/super-pom.html其中包含此条目:

All pom files inherit from the maven super POM http://maven.apache.org/ref/3.0.4/maven-model-builder/super-pom.html which contains this entry:

<repositories>
    <repository>
        <id>central</id>
        <name>Central Repository</name>
        <url>http://repo.maven.apache.org/maven2</url>
        <layout>default</layout>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

尝试在你的 pom 中设置它(使用 central):

Try setting this in your pom (with <id>central</id>):

<repositories>
    <repository>
        <id>central</id>
        <url>http://repo.dev.bloomberg.com/content/groups/public</url>
        <releases>
            <enabled>false</enabled>
        </releases>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>central</id>
        <url>http://repo.dev.bloomberg.com/content/groups/public</url>
        <releases>
            <enabled>false</enabled>
        </releases>
    </pluginRepository>
</pluginRepositories>

这篇关于你如何阻止 maven 尝试访问 http://repo.maven.apache.org?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆