Project不会识别任何maven依赖项

时间:2016-04-05 05:30:30

标签: java maven jar

当我{strong}项目:

maven install时,我收到以下错误消息
Failed to execute goal on project xxx Could not resolve dependencies for project yyy:xxx:1.0: 
Failed to collect dependencies for [log4j:log4j:jar:1.2.9 (compile), junit:junit:jar:3.8.1 (compile), yyy:framework:jar:1.0 (compile), ant:ant:jar:1.6.2 (compile), 
commons-beanutils:commons-beanutils:jar:1.6.1 (compile), commons-collections:commons-collections:jar:3.1 (compile), 
commons-dbcp:commons-dbcp:jar:1.2.1 (compile), commons-digester:commons-digester:jar:1.5 (compile), 
commons-fileupload:commons-fileupload:jar:1.0 (compile), commons-lang:commons-lang:jar:2.0 (compile), 
commons-logging:commons-logging:jar:1.0.3 (compile), commons-pool:commons-pool:jar:1.2 (compile), 
commons-validator:commons-validator:jar:1.0.2 (compile), xalan:xalan:jar:2.5.1 (compile), 
xerces:xercesImpl:jar:2.4.0 (compile), xml-apis:xml-apis:jar:1.0.b2 (compile), com.oracle:ojdbc14:jar:9.0.2.0.0 (compile),
 hsqldb:hsqldb:jar:1.7.1 (compile), p6spy:p6spy:jar:1.1 (compile), hibernate:hibernate:jar:2.1.6 (compile), 
 javax.transaction:jta:jar:1.1 (compile), ehcache:ehcache:jar:0.9 (compile), c3p0:c3p0:jar:0.8.4.5 (compile), 
cglib:cglib:jar:2.0.1 (compile), dom4j:dom4j:jar:1.4 (compile), odmg:odmg:jar:3.0 (compile), 
 javax.xxx:xxx:jar:api:2.1 (compile), com.lowagie:itext:jar:1.3.1 (compile), org.slf4j:slf4j-api:jar:1.6.1 (compile),
 org.slf4j:slf4j-nop:jar:1.6.1 (compile), org.dbunit:dbunit:jar:2.4.8 (compile), xdoclet:xdoclet-ejb-module:jar:1.2.3 (compile), 
 xdoclet:xdoclet:jar:1.2.3 (compile), xdoclet:xdoclet-hibernate-module:jar:1.2.3 (compile), 
 xdoclet:xjavadoc:jar:1.5 (runtime)]:
 Failed to read artifact descriptor for commons-beanutils:commons-beanutils:jar:1.4-dev: Could not transfer artifact commons-beanutils:commons-beanutils:pom:1.4-dev: ConnectException: UnresolvedAddressException -> [Help 1]

这些依赖关系都包含在我的pom.xml中。知道怎么解决这个问题吗?我试过添加一个settings.xml,但是徒劳无功。 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
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>C:\Users\abc\.m2\repository</localRepository>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <servers/>
  <mirrors/>
  <proxies/>
  <profiles/>
  <activeProfiles/>

请帮助,我被困住了。

2 个答案:

答案 0 :(得分:0)

您需要将settings.xml配置为指向托管您正在查找的工件的一个或多个存储库。它们将被下载到您的本地存储库中。例如:

<profiles>
    <profile>
        <id>central</id>
        <activation>
           <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
                <id>central</id>
                <url>http://repo1.maven.org/maven2</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <url>http://repo1.maven.org/maven2</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>
</profiles>

答案 1 :(得分:0)

我不确定您是否可以在计算机上阅读其他用户的文件。将maven存储库重新定位到另一个路径,例如C:/ maven_repository,并在maven设置中更改本地路径。这个案子适合我。