无法解决与maven的依赖关系

时间:2011-10-13 03:58:14

标签: maven ejb repository maven-descriptor

我似乎无法对maven做任何事情,因为它无法下载其依赖项。当我尝试从http://openejb.apache.org/ejb3-tutorial.html运行示例应用程序时,它给了我一些错误:

D:\apache-maven-3.0.3\openejbsamples\simple-stateless>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building OpenEJB :: Examples :: Simple Stateless Pojo 1.0
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.454s
[INFO] Finished at: Thu Oct 13 11:47:26 CST 2011
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.ap
ache.maven.plugins:maven-clean-plugin:jar:2.4.1: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1 from/to central (http://repo1
.maven.org/maven2): Error transferring file: repo1.maven.org: Unknown host repo1.maven.org -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

为什么我不能下载存储库?

更新:没关系。我的老板告诉我,由于公司的代理设置,我不能这样做。无论如何,我只是想在不使用maven的情况下以最快的方式研究ejb?如果可能的话?

5 个答案:

答案 0 :(得分:2)

请查看Using Proxies With Maven,因为问题最有可能是因为您拥有“异国情调”的互联网连接。 (防火墙,dns覆盖,其他代理等。)

如果您确实支持代理,并且需要用户名/密码,请查看cntlm

答案 1 :(得分:2)

看起来您有主机名查找问题:Unknown host repo1.maven.org。这是中央Maven存储库的正确主机名。检查您的DNS设置和/或您可能拥有的任何本地主机名覆盖。当然,如果您使用公司DNS并且您的互联网访问通常受到限制,那可能就是它。

答案 2 :(得分:0)

如果您不允许进行代理配置(安全问题),也许您可​​以说服您的老板和网络管理员在某个开发服务器中设置本地maven存储库。查看此链接(如果您的代理和您的网络管理员都可以使用它......当然:P)http://www.theserverside.com/news/1364121/Setting-Up-a-Maven-Repository

答案 3 :(得分:0)

我也在努力解决这个问题......这就是我修复的方法......

settings.xmlMaven_HOME\conf directory下)

我添加了代理条目,如下所示

<proxies>
    <proxy>
        <active>true</active>
        <protocol>http</protocol>
        <host>IPAddressOfYourGateway</host>
        <port>8080</port>
        <username>YourNetworkUserName</username>
        <password>YourNetworkPassword</password>
        <nonProxyHosts>LocalIPAddress1|LocalIPAddress2|LocalIPAddress3</nonProxyHosts>
     </proxy>
 </proxies>

其中,

1)“IPAddressOfYourGateway”可以从IEExplorer获得 - &gt;设置 - &GT;代理..这是您的代理的IP地址..

2)LocalIPAddress1 | LocalIPAddress2 ..“|” ..管道标志用于添加多个IP地址......需要从代理中绕过... 您需要与您的网络团队核实该端口,以防它在您的情况下不起作用...

答案 4 :(得分:0)

在settings.xml中添加以下内容对我有用

<profiles>
    <profile>
            <id>outsideMyWorld</id>
            <repositories>
        <repository>
                <id>central</id>
                <url>http://repo1.maven.org/maven2</url>
                <snapshots>
            <enabled>false</enabled>
                </snapshots>
                <releases>
            <enabled>true</enabled>
                </releases>
        </repository>
            </repositories>
    </profile>
</profiles>

<activeProfiles>
        <activeProfile>outsideMyWorld</activeProfile>
</activeProfiles>