-
Notifications
You must be signed in to change notification settings - Fork 41.8k
Description
I am upgrading a sample application using Kafka from Spring Boot 3.5 to 4 and I run into the issue that there is no autoconfiguration of the transaction manager.
When I create a new application on start.spring.io, adding only "Spring for Apache Kafka" using both 3.5.9 and 4.0.1, then I notice that 3.5.9 has the TransactionAutoConfiguration class on the classpath, while the 4.0.1 version does not have this.
This is the mvn dependency:tree for 3.5.9:
[INFO] +- org.springframework.boot:spring-boot-starter:jar:3.5.9:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:3.5.9:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:3.5.9:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:3.5.9:compile
[INFO] | | +- ch.qos.logback:logback-classic:jar:1.5.22:compile
[INFO] | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.24.3:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-api:jar:2.24.3:compile
[INFO] | | \- org.slf4j:jul-to-slf4j:jar:2.0.17:compile
[INFO] | +- jakarta.annotation:jakarta.annotation-api:jar:2.1.1:compile
[INFO] | +- org.springframework:spring-core:jar:6.2.15:compile
[INFO] | | \- org.springframework:spring-jcl:jar:6.2.15:compile
[INFO] | \- org.yaml:snakeyaml:jar:2.4:compile
[INFO] +- org.springframework.kafka:spring-kafka:jar:3.3.11:compile
[INFO] | +- org.springframework:spring-context:jar:6.2.15:compile
[INFO] | | +- org.springframework:spring-aop:jar:6.2.15:compile
[INFO] | | +- org.springframework:spring-beans:jar:6.2.15:compile
[INFO] | | \- org.springframework:spring-expression:jar:6.2.15:compile
[INFO] | +- org.springframework:spring-messaging:jar:6.2.15:compile
[INFO] | +- org.springframework:spring-tx:jar:6.2.15:compile
[INFO] | +- org.springframework.retry:spring-retry:jar:2.0.12:compile
[INFO] | +- org.apache.kafka:kafka-clients:jar:3.9.1:compile
[INFO] | | +- com.github.luben:zstd-jni:jar:1.5.6-4:runtime
[INFO] | | +- org.lz4:lz4-java:jar:1.8.0:runtime
[INFO] | | +- org.xerial.snappy:snappy-java:jar:1.1.10.5:runtime
[INFO] | | \- org.slf4j:slf4j-api:jar:2.0.17:compile
[INFO] | \- io.micrometer:micrometer-observation:jar:1.15.7:compile
[INFO] | \- io.micrometer:micrometer-commons:jar:1.15.7:compile
The class is coming from the spring-boot-autoconfigure jar.
This is the tree for the 4.0.1 version:
[INFO] +- org.springframework.boot:spring-boot-starter-kafka:jar:4.0.1:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:4.0.1:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:4.0.1:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.5.22:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.5.22:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.25.3:compile
[INFO] | | | \- org.slf4j:jul-to-slf4j:jar:2.0.17:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:4.0.1:compile
[INFO] | | +- jakarta.annotation:jakarta.annotation-api:jar:3.0.0:compile
[INFO] | | \- org.yaml:snakeyaml:jar:2.5:compile
[INFO] | \- org.springframework.boot:spring-boot-kafka:jar:4.0.1:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:4.0.1:compile
[INFO] | \- org.springframework.kafka:spring-kafka:jar:4.0.1:compile
[INFO] | +- org.springframework:spring-messaging:jar:7.0.2:compile
[INFO] | +- org.springframework:spring-tx:jar:7.0.2:compile
[INFO] | +- org.apache.kafka:kafka-clients:jar:4.1.1:compile
[INFO] | \- io.micrometer:micrometer-observation:jar:1.16.1:compile
[INFO] | \- io.micrometer:micrometer-commons:jar:1.16.1:compile
spring-boot-autoconfigure is also there, but probably does not have the Kafka autoconfigurations anymore with the new modular design?
If I manually add this dependency in the 4.0.1 version:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-transaction</artifactId>
</dependency>
Then the transactions are created.
I also saw this stackoverflow question which seems to indicate the same behaviour.
Do we need to manually add spring-boot-transaction with Spring Boot 4.0.1, or should this be transitively included when depending on spring-boot-starter-kafka? If the former, maybe add this to the migration guide. If the latter, then this is a bug I guess?