【问题标题】:Maven Dependency Management is importing wrong versionMaven 依赖管理正在导入错误的版本
【发布时间】:2021-08-20 20:06:51
【问题描述】:

我正在克隆项目以导入 7.13 版本的依赖项,如此处所述。正如您所看到的,camunda-webapp: 7.11.0(从 7.13.0 管理)正在蔓延。这导致了一些 ClassNotFoundExceptions,因为我需要camunda-webapp: 7.13.0,这在我不拥有的差异项目中正确发生。我做了很多挖掘和排除,但我无法弄清楚这整个 7.11.0 (managed from 7.13.0) 是从哪里来的。

我如何强制这个项目始终使用7.13.0

但是,在另一个导入 7.13 的项目中,正确导入了传递 7.13。

编辑 - 在此处更新 POM 以对修复进行分类:

<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>org.camunda.bpm.getstarted</groupId>
  <artifactId>camunda-ctil-cockpit</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <properties>
    <camunda.spring-boot.version>7.13.0</camunda.spring-boot.version>
    <spring-boot.version>2.3.9.RELEASE</spring-boot.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <capitalone.camunda.plugin.version>1.5</capitalone.camunda.plugin.version>
  </properties>
  
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring-boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>com.capitalone.camunda.plugins</groupId>
        <artifactId>plugin-dependencies</artifactId>
        <version>${capitalone.camunda.plugin.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>

  </dependencyManagement>
  
  <dependencies>
    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
      <version>${camunda.spring-boot.version}</version>
      <exclusions>
        <exclusion>
            <groupId>org.camunda.bpm.webapp</groupId>
            <artifactId>camunda-webapp-webjar</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
      <version>${camunda.spring-boot.version}</version>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

    <dependency>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-impl</artifactId>
      <version>2.2.3</version>
    </dependency>
    <dependency>
      <groupId>com.capitalone.camunda.plugins</groupId>
      <artifactId>capitalone-uioverlay</artifactId>
      <exclusions>
        <exclusion>
            <groupId>org.camunda.bpm.webapp</groupId>
            <artifactId>camunda-webapp</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.capitalone.camunda.plugins</groupId>
      <artifactId>spring-plugin-commons</artifactId>
    </dependency>
    <dependency>
      <groupId>com.capitalone.camunda.plugins</groupId>
      <artifactId>custom-engine-types</artifactId>
      <exclusions>
        <exclusion>
            <groupId>org.camunda.bpm.webapp</groupId>
            <artifactId>camunda-webapp</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.capitalone.camunda.plugins</groupId>
      <artifactId>common-cockpit-extensions</artifactId>
      <exclusions>
        <exclusion>
            <groupId>org.camunda.bpm.webapp</groupId>
            <artifactId>camunda-webapp</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm.identity</groupId>
      <artifactId>camunda-identity-ldap</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-oauth2</artifactId>
    </dependency>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.18.2</version>
    </dependency>

    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.6</version>
    </dependency>

    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
    </dependency>
  </dependencies>
  
   <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>${spring-boot.version}</version>
        <configuration>
          <layout>ZIP</layout>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
     <finalName>camunda-ctil-cockpit</finalName>
  </build>
  
</project>

但是结果仍然存在。如您所见,7.11 仍然存在。如果我完全排除 7.11,camunda-webapp.jar 将完全消失。希望 7.13 会弹出。与上面的屏幕截图相比,camunda-webapp-webjar 也被完全删除:

【问题讨论】:

  • 你能给我们看看实际的 XML 吗?
  • 添加了原始 POM
  • 看起来版本来自&lt;dependencyManagement&gt;,即来自范围为import的条目之一。

标签: maven plugins camunda


【解决方案1】:

先改变属性值

<camunda.spring-boot.version>3.2.0</camunda.spring-boot.version>

7.13.0 参见例如https://start.camunda.com/

如果问题仍然存在,插件 jar 会定义自己的版本,而不是由 BOM 驱动:

您共享了主项目 POM,包括引擎和 web 应用程序,但不需要的依赖项作为您的自定义 com.capitalone.* jar 的依赖项进入,如依赖关系树的屏幕截图所示。 camunda-webapp:7.11.0 是由

引入的依赖项
1)
<dependency>
      <groupId>com.capitalone.camunda.plugins</groupId>
      <artifactId>capitalone-uioverlay</artifactId>
    </dependency>
2)  
    <dependency>
      <groupId>com.capitalone.camunda.plugins</groupId>
      <artifactId>custom-engine-types</artifactId>
    </dependency>
3)
    <dependency>
      <groupId>com.capitalone.camunda.plugins</groupId>
      <artifactId>common-cockpit-extensions</artifactId>
    </dependency>

A) 如果可能,更新这些项目的 POM 并在它们上运行 mvn clean install

B) 如果您无法控制这些项目,那么您还可以将排除项添加到上面列出的依赖项标记中(因为 jar 已经包含在主项目中)。但是,这意味着您的插件 jar 使用另一个 jar 版本运行,而不是针对它们进行编译。这不是一个好的做法,如果兼容性发生变化,可能会导致问题。

换个说法: “请注意,我们使用 Camunda Platform Runtime 7.14 更新了前端插件界面。为 Camunda Platform Runtime 7.13 及更早版本编写的插件可能不再适用于 Camunda Platform Runtime 7.14。查看更新指南了解更多详细信息。” https://docs.camunda.org/manual/latest/webapps/cockpit/extend/plugins/

【讨论】:

  • 在开头添加了另一个注释。如果插件继承 BOM,它的版本会影响它们。谁做了:很高兴发表评论。无声的无声投票无助于解决方案,这绝对在我的回答范围内
  • 根据上述建议更新了 Pom(为新更改添加了 EDIT)。我不拥有指定的依赖项,因此我向 camunda-webapp 发出了排除项。 (我已经更新了原始 POM 以便于阅读。但是 camunda-webapp 7.11 仍然显示在 camunda -bpm-spring-boot-starter-webapp.core 下(我已经在主页面的底部推送了屏幕截图和更新了 POM线程)和 camunda-webapp-webjar 消失,如更新屏幕截图所示。我需要某种方式强制 camunda webapp 和 camunda-webapp-webjar 7.13 按预期显示
  • 请在POM文件夹中命令行运行a:mvn dependency:tree并分享结果(可以替换截图)
猜你喜欢
  • 2019-07-23
  • 2021-07-11
  • 2015-10-17
  • 2017-11-28
  • 2015-10-13
  • 1970-01-01
  • 2015-04-03
  • 1970-01-01
相关资源
最近更新 更多