簡體   English   中英

Maven本地存儲庫未使用最新依賴項更新

[英]Maven local repo not updated with latest dependency

我的項目有一個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>

在執行“ MVN部署”之后,我確實瀏覽了遠程存儲庫,並且在那里看到了項目

我還有一個依賴於上述“ ProjectMav”的項目,它的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> update項目,它不會將“ ProjectMav”的最新版本發送到本地存儲庫。

但是,如果我清除本地存儲庫中的所有文件並進行Maven更新,它將得到我的項目

知道發生了什么嗎?

我認為問題在於,Maven eclipse插件的update實際上並未進行mvn install ,而這是您要覆蓋1.0部署版本時需要的。 mvn eclipse插件對類路徑依賴項進行排序的方式(您可以在軟件包資源管理器中清楚地看到,是先將依賴項jar放入,然后將已解決的上游項目放在jar后面)。 對於SNAPSHOT項目,這似乎很好用,因為該插件知道使用您的項目而不是jar,但對於發布jar,它會感到困惑(或者至少我注意到了)。

話雖這么說,您應該將本地版本更改為:

<version>1.1-SNAPSHOT</version>

然后,在依賴ProjectMav下游項目中,將其依賴項更新為1.1-SNAPSHOT 版本管理可能很棘手,因此您可能需要研究maven版本插件,並在部署時讓它處理項目的版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM