首页 > 解决方案 > Maven 依赖管理正在导入错误的版本

问题描述

我正在克隆项目以导入 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与上面的屏幕截图相比,也被完全删除: 在此处输入图像描述

标签: mavenpluginscamunda

解决方案


首先更改的属性值

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

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

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

您共享了包含引擎和 webapps 的主项目 POM,但不需要的依赖项作为您的自定义 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/


推荐阅读