maven编译失败,因为不可用依赖项

时间:2013-07-09 14:51:11

标签: maven maven-2 maven-plugin

我正在尝试使用maven运行java程序但是当我使用命令mvn -U compile编译时 他告诉我以下错误

[root@onePK-EFT1 tutorials]# mvn -U compile
[INFO] Scanning for projects...
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building onePK Java Tutorials 0.6.0.5
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/com/cisco/onep/libonep-core-rel
/0.6.0.5/libonep-core-rel-0.6.0.5.pom
[WARNING] The POM for com.cisco.onep:libonep-core-rel:jar:0.6.0.5 is missing, no 
dependency information available
Downloading: http://repo.maven.apache.org/maven2/com/cisco/onep/libonep-
core-rel/0.6.0.5/libonep-core-rel-0.6.0.5.jar
[INFO] ------------------------------------------------------------------------
INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.517s
[INFO] Finished at: Tue Jul 09 07:28:28 PDT 2013
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project java-tutorials: Could not resolve 
dependencies for project com.cisco.onep:java-tutorials:jar:0.6.0.5: Could not find 
artifact com.cisco.onep:libonep-core-rel:jar:0.6.0.5 in central 
(http://repo.maven.apache.org/maven2) -> [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   
/DependencyResolutionException

这是我的pom.xml文件

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org  
 /2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cisco.onep</groupId>
<artifactId>hello-network-app</artifactId>
<version>0.1-SNAPSHOT</version>
<name>The onePK Hello Network Example Application</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12</version>
            <configuration>
                <forkMode>always</forkMode>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.8</version>
            <configuration>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>com.cisco.onep</groupId>
        <artifactId>libonep-core-rel</artifactId>
        <version>0.6.0.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.thrift</groupId>
        <artifactId>libthrift</artifactId>
        <version>0.6.1</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.1</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
    </dependency>
</dependencies>

<developers>
    <developer>
        <name>onePK Team</name>
        <email>onepk-feedback@cisco.com</email>
        <organization>Cisco.com</organization>
    </developer>
</developers>

我认为这是因为他找不到我所包含的libonep-core-rel.jar 请任何帮助

2 个答案:

答案 0 :(得分:2)

简单的解决方案是为不在Maven中心的工件com.cisco.onep*使用适当的maven存储库。

答案 1 :(得分:0)

作为即时解决方案,但不是推荐,您可以使用system dependencies来解析本地文件系统上的工件。

正如@khmarbaise暗示的那样,尝试将这些公司工件发布到您的公司Maven存储库(Nexus,Artifactory,Archiva等),甚至FTP / HTTP服务器也会这样做......

将这些公司工件发布到“公司”存储库后(希望它已经存在),您只需要在Maven POM中使用new repository declaration