Maven本地仓库没有更新最新的依赖

时间:2014-12-04 19:42:13

标签: eclipse maven maven-2 maven-3 maven-plugin

我的项目有一个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>ProjectMav</groupId>
<artifactId>ProjectMav</artifactId>
<version>1.0</version>
<distributionManagement>
    <repository>
        <id>man-release</id>
        <name>mav release repo</name>
        <url>http://xxxxxx.net/repositories/mav-release/</url>
    </repository>
    <snapshotRepository>
        <id>mav-snapshots</id>
        <name>mav snapshots repo</name>
        <url>http://xxxxxx.net/repositories/mav-snapshots/</url>
    </snapshotRepository>
</distributionManagement>
<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

在我执行了“部署”之后我确实浏览了远程存储库,我看到那里的项目

我有另一个项目取决于上面提到的&#39; ProjectMav&#39;它的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>mavtest</groupId>
<artifactId>mavtest-suite</artifactId>
<version>1.0</version>
<dependencies>
    <dependency>
        <groupId>ProjectMav</groupId>
        <artifactId>ProjectMav</artifactId>
        <version>1.0</version>
        <scope>compile</scope>
    </dependency>
</dependencies>
<repositories>
    <repository>
        <id>mav-release</id>
        <name>mav release repo</name>
        <url>http://xxxxxx.net/repositories/mav-release/</url>
    </repository>
</repositories>
<build>
    <testSourceDirectory>src/com/mav/</testSourceDirectory>
    <resources>
        <resource>
            <directory>/resources</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

现在从eclipse开始,如果我做了一个Maven&gt;更新项目,它就不会得到我的&#39; ProjectMav&#39;的最新版本。到我的本地存储库。

但如果我清除本地仓库中的所有文件并进行maven更新,它就会获得我的项目

知道发生了什么事吗?

1 个答案:

答案 0 :(得分:1)

我认为问题是maven eclipse插件的update实际上没有mvn install,如果你想覆盖1.0部署的版本,那就是你需要的。 mvn eclipse插件命令类路径依赖关系的方式(你可以在包资源管理器中清楚地看到)是首先放置依赖jar,然后是jar之后解析的上游项目。这似乎适用于SNAPSHOT项目,因为插件知道使用你的项目而不是罐子,但是对于发布罐子它会变得混乱(或者至少我已经注意到它)。

话虽如此,您应该通过将本地版本更改为:

来完全避免此问题
<version>1.1-SNAPSHOT</version>

然后,在依赖ProjectMav的下游项目中,您将其依赖关系更新为1.1-SNAPSHOT。版本管理可能很棘手,因此您可能需要查看maven发布插件,并在部署时处理项目的版本控制。

相关问题