无法解决maven中的依赖项错误

时间:2014-05-09 11:59:55

标签: maven

我有一个多模块maven项目:

portlet
     mapadmin
util-java
     EngineService
     Shapeloader
     staticmap

mapadmin是portlet的子项,EngineService,Shapeloader,staticmap是util-java的子项。 我在staticmap和mapadmin中使用EngineService类。所以我在staticmap和mapadmin中添加了EngineService的依赖项:

<dependency>
    <groupId>ir.nsdp.satra</groupId>
    <artifactId>EngineService</artifactId>
    <version>1.0</version>
</dependency>

此依赖项在staticamp中有效但在mapadmin中会出错(无法解析依赖项)。 我已成功安装EngineService,它出现在.m2文件夹中。

确切错误:

[ERROR] Failed to execute goal on project mapadmin-portlet: Could not resolve dependencies for project ir.nsdp.satra:mapadmin-portlet:war:1.0: Failed to collect dependencies at ir.nsdp.satra:EngineService:jar:1.0: Failed to read artifact descriptor for ir.nsdp.satra:EngineService:jar:1.0: Failure to find ir.nsdp.satra:Satra:pom:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced

这是我的EngineService pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
    <artifactId>util-java</artifactId>
    <groupId>ir.nsdp.satra</groupId>
    <version>1.0</version>
  </parent>

    <artifactId>EngineService</artifactId>
    <packaging>jar</packaging>
    <name>Satra Utils</name>

    <prerequisites>
        <maven>${mavenVersion}</maven>
    </prerequisites>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <geotools.version>10.3</geotools.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>portal-service</artifactId>
            <version>6.0.6</version>
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-wms</artifactId>
            <version>${geotools.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>ir.nsdp.satra</groupId>
            <artifactId>mapadmin-portlet-service</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>maven2-repository.dev.java.net</id>
            <name>Java.net repository</name>
            <url>http://download.java.net/maven/2</url>
        </repository>
        <repository>
            <id>osgeo</id>
            <name>Open Source Geospatial Foundation Repository</name>
            <url>http://download.osgeo.org/webdav/geotools/</url>
        </repository>
    </repositories>

    <build>
    <finalName>satra-${project.artifactId}</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <configuration>
                        <outputDirectory>${basedir}/../../web/src/main/docroot/WEB-INF/lib</outputDirectory>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

我不知道问题的所有细节,但尝试执行以下操作:

cd util-java
mvn install
cd ../portlet/mapadmin
mvn compile

答案 1 :(得分:0)

如果您查看错误消息,您会看到接近结尾:

 Failed to read artifact descriptor for ir.nsdp.satra:EngineService:jar:1.0:
 Failure to find ir.nsdp.satra:Satra:pom:1.0 in
 http://repo.maven.apache.org/maven2 was cached in the local repository,
 resolution will not be reattempted until the update interval of central
 has elapsed or updates are forced

这意味着ir.nsdp.satra:EngineService:jar:1.0具有依赖关系ir.nsdp.satra:Satra:pom:1.0

当Maven上次看时,这种依赖关系既不在$HOME/.m2/repository也不在Maven Central。它将在明天再次运行,或者当您使用mvn运行--update-snapshots时(与名称不同,它将再次查看缺失的版本)。

尝试在包含缺失POM的项目中运行mvn install

相关问题