0

I have a library named lib-kafka-wrapper that uses kafka-clients:2.8.0 dependency:

    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-clients</artifactId>
        <version>2.8.0</version>
    </dependency>

mvn dependency:tree shows correctly:

[INFO] com.mycronic.as.cdp:lib-kafka-wrapper:jar:0.5.6
[INFO] +- org.apache.kafka:kafka-clients:jar:2.8.0:compile

But if I use lib-kafka-wrapper in another project:

    <dependency>
        <groupId>com.mycronic.as.cdp</groupId>
        <artifactId>lib-kafka-wrapper</artifactId>
        <version>0.5.6</version>
    </dependency>

it keeps downloading version kafka-clients:3.0.0:

[INFO] com.mycronic.as.cdp:app-pnp-analytics:jar:1.1.2-SNAPSHOT
[INFO] +- com.mycronic.as.cdp:lib-kafka-wrapper:jar:0.5.6:compile
[INFO] |  +- org.apache.kafka:kafka-clients:jar:3.0.0:compile

Edit:

pom.xml start:

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

Any idea what do I wrong?

Michal Špondr
  • 1,337
  • 2
  • 21
  • 44
  • Use `` to set versions of transitive dependencies. Also: `dependency:tree -Dverbose=true` – Stanislav Bashkyrtsev Jan 07 '22 at 09:12
  • @StanislavBashkyrtsev Thanks for dependencyManagement tag, I'll read something about it. But I've thought I do not need to override version number of kafka-clients as it is already defined in lib-kafka-wrapper. I do not know why the newer version is downloaded even if it's not mentioned anywhere else in pom files. – Michal Špondr Jan 07 '22 at 09:28
  • 1
    Do you have Spring Boot `import` defined or maybe a `` where it's defined? Run `mvn help:effective-pom` to find all the actual configuration of the module. – Stanislav Bashkyrtsev Jan 07 '22 at 10:28
  • Please show your full pom file... – khmarbaise Jan 07 '22 at 11:03
  • @StanislavBashkyrtsev Actually I use Spring Boot. I've added beginning of pom.xml to the question. mvn help:effective-pom shows occurences with a lot of org.apache.kafka:* libraries version 3.0.0 and also it contains 3.0.0 in . I assume these dependencies are brought into project by Spring boot. – Michal Špondr Jan 07 '22 at 12:28
  • @MichalŠpondr, yep - you can override them by overriding the properties or using your own `` – Stanislav Bashkyrtsev Jan 07 '22 at 12:35
  • It seems odd to use `spring-boot-starter-parent` for a project which isn't a spring boot application. – tgdavies Jan 08 '22 at 06:55

0 Answers0