简体   繁体   English

Maven 不使用较新的本地构建/安装依赖项

[英]Maven not using newer locally built/installed dependency

I've been hitting an annoying issue recently.我最近遇到了一个烦人的问题。 I have two different maven projects checked out to my development machine.我有两个不同的 Maven 项目检出到我的开发机器上。 One project depends on the other (let's say Project A depends on Project B), and I actively make changes to both projects.一个项目依赖于另一个(假设项目 A 依赖于项目 B),我积极地对这两个项目进行了更改。 Sometimes though, Project A won't pick up the latest Project B changes.但有时,项目 A 不会获取最新的项目 B 更改。 Let's say I make some changes to Project B, I build/install it with...假设我对项目 B 进行了一些更改,我构建/安装它...

mvn clean install

I even check my local ~/.m2/repository to see that the jar has been updated.我什至检查我的本地 ~/.m2/repository 以查看 jar 已更新。 But Project A will still continue to use an older version of Project B. Even though it was just updated... If I remove the entire Project B folder, as in...但项目 A 仍将继续使用项目 B 的旧版本。即使它刚刚更新......如果我删除整个项目 B 文件夹,如......

rm -rf ~/.m2/repository/project-b/version/

And then build/install Project B again, then at this point my problem is gone.然后再次构建/安装项目 B,此时我的问题就消失了。 Project A will finally make use of the updated Project B. But I don't want to have to go through this exercise every time.项目 A 最终将使用更新后的项目 B。但我不想每次都进行这个练习。 Any clues what could be causing this?任何可能导致这种情况的线索?

Edit: Here's more or less the relevant parts of the pom.xml for both projects.编辑:这里或多或少是两个项目的 pom.xml 的相关部分。 It's extremely basic.这是非常基本的。

Project A pom.xml项目 A pom.xml

<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.opendaylight.mdsal</groupId>
    <artifactId>binding-parent</artifactId>
    <version>3.0.10</version>
    <relativePath/>
  </parent>

  <groupId>company.group</groupId>
  <version>1.0.0-SNAPSHOT</version>
  <artifactId>project-A</artifactId>
  <packaging>bundle</packaging>

  <dependencies>
    <dependency>
      <groupId>company.group</groupId>
      <artifactId>project-B</artifactId>
      <version>3.1.0-SNAPSHOT</version>
    </dependency>
    ...
  </dependencies>
</project>

Project B pom.xml项目 B 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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>company.group</groupId>
    <artifactId>project-B-parent</artifactId>
    <version>3.1.0-SNAPSHOT</version>
  </parent>

  <groupId>company.group</groupId>
  <artifactId>project-B</artifactId>
  <version>3.1.0-SNAPSHOT</version>
  <packaging>bundle</packaging>

  <dependencies>
     ...
  <dependencies>
</project>

Since you are using IntelliJ in the right upper corner there is this maven menu, where you can reimport all dependencies which helps me in this case :)由于您在右上角使用 IntelliJ,因此有这个 maven 菜单,您可以在其中重新导入所有依赖项,这在这种情况下对我有帮助:)

由于您在右上角使用 IntelliJ,因此有这个 maven menue,您可以在其中重新导入所有依赖项,这在这种情况下对我有帮助:=

Try below maven command for loading all updated libraries,尝试使用以下 Maven 命令加载所有更新的库,

mvn clean install -U mvn 干净安装 -U

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM