feat(spring-wolf-example): update Kafka bindings and improve Dockerfi…#184
Conversation
…le for better compatibility
WalkthroughUpgrades the Spring Boot example project from version 3.5.10 to 4.0.2, updates Maven wrapper and plugin versions, refactors Kafka consumer to accept Spring Message wrappers instead of raw payloads, and aligns message broker binding names for consistency. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@spring-wolf-example/.mvn/wrapper/maven-wrapper.properties`:
- Line 3: Update the Maven wrapper distribution referenced in
.mvn/wrapper/maven-wrapper.properties by changing the distributionUrl value from
apache-maven-4.0.0-rc-4 to apache-maven-4.0.0-rc-5 (i.e., point distributionUrl
to the rc-5 binary), then run the wrapper (mvn -N io.takari:maven:wrapper or
./mvnw -v) to verify the new wrapper works and update any CI cache or
documentation that references the old RC.
In `@spring-wolf-example/Dockerfile`:
- Line 19: The Dockerfile uses an unsafe glob "mv target/*.jar target/app.jar"
which fails if multiple jars are produced; change this to move a single specific
artifact (e.g., the repackaged fat JAR name such as "*-boot.jar" or your
artifactId-version.jar) or programmatically pick one jar (e.g., select the first
non-original/repacked jar and rename it to app.jar) before moving; update the mv
invocation in the Dockerfile (the line with mv target/*.jar target/app.jar) to
reference the chosen single-file selection method.
In `@spring-wolf-example/pom.xml`:
- Line 23: The POM sets maven.plugin.version to the pre-release "4.0.0-beta-4"
which is not recommended for production; update the maven.plugin.version
property to the stable release "3.15.0" and ensure the maven-compiler-plugin
reference uses that property (search for maven.plugin.version and the
maven-compiler-plugin plugin configuration in the POM) so the build uses the
stable compiler plugin instead of the beta.
In
`@spring-wolf-example/src/main/java/com/io/example/producer/KafkaProducer.java`:
- Line 39: The StreamBridge binding name used in KafkaProducer
(bridge.send("kafkaV2Producer-out-0", message)) does not match the binding
defined in application.yaml (kafkaProducer-out-0), causing a dynamic binding and
wrong topic; fix by making the names identical — either change the KafkaProducer
call to bridge.send("kafkaProducer-out-0", message) so it uses the configured
destination (${kafka.topics.simple-topic}), or update the YAML binding key from
kafkaProducer-out-0 to kafkaV2Producer-out-0; ensure the StreamBridge binding
name exactly matches the binding id in application.yaml so the configured
destination is used.
---
Duplicate comments:
In `@spring-wolf-example/src/main/resources/application.yaml`:
- Around line 17-18: The binding name in application.yaml (kafkaProducer-out-0)
doesn't match the producer's StreamBridge.send() destination
("kafkaV2Producer-out-0") so the binding is unused; update the YAML key to
"kafkaV2Producer-out-0" to match the StreamBridge.send() call in
KafkaProducer.java (or alternatively change the StreamBridge.send() argument in
KafkaProducer.send.../class KafkaProducer to "kafkaProducer-out-0" if you prefer
to keep the YAML), ensuring the binding name and the StreamBridge destination
string are identical.
| wrapperVersion=3.3.4 | ||
| distributionType=only-script | ||
| distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip | ||
| distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/4.0.0-rc-4/apache-maven-4.0.0-rc-4-bin.zip |
There was a problem hiding this comment.
Maven 4.0.0-rc-4 is not the latest release candidate; rc-5 is available.
Maven 4.0.0-rc-4 aims at being the last release candidate before Maven 4.0.0 GA. However, a new release candidate, 4.0.0-rc-5, was released on Nov 13. Note that a bug has been found in the bean configuration system where field accessibility state is cached globally. This can cause plugin configuration injection to fail when the same configuration field is accessed multiple times or in different contexts during a build. Consider updating to rc-5 or waiting for GA.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@spring-wolf-example/.mvn/wrapper/maven-wrapper.properties` at line 3, Update
the Maven wrapper distribution referenced in
.mvn/wrapper/maven-wrapper.properties by changing the distributionUrl value from
apache-maven-4.0.0-rc-4 to apache-maven-4.0.0-rc-5 (i.e., point distributionUrl
to the rc-5 binary), then run the wrapper (mvn -N io.takari:maven:wrapper or
./mvnw -v) to verify the new wrapper works and update any CI cache or
documentation that references the old RC.
| --mount=type=cache,target=/root/.m2 \ | ||
| ./mvnw package -DskipTests && \ | ||
| mv target/$(./mvnw help:evaluate -Dexpression=project.artifactId -q -DforceStdout)-$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout).jar target/app.jar | ||
| mv target/*.jar target/app.jar |
There was a problem hiding this comment.
Wildcard *.jar glob may match multiple files, causing mv to fail.
If the build produces more than one .jar in target/ (e.g., a plain archive alongside the repackaged fat JAR), mv target/*.jar target/app.jar will error out because mv cannot rename multiple source files to a single non-directory destination.
Consider being more specific, e.g., using the artifact name or ensuring only one JAR exists:
Proposed fix
- mv target/*.jar target/app.jar
+ mv target/springwolf-example-*.jar target/app.jar📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| mv target/*.jar target/app.jar | |
| mv target/springwolf-example-*.jar target/app.jar |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@spring-wolf-example/Dockerfile` at line 19, The Dockerfile uses an unsafe
glob "mv target/*.jar target/app.jar" which fails if multiple jars are produced;
change this to move a single specific artifact (e.g., the repackaged fat JAR
name such as "*-boot.jar" or your artifactId-version.jar) or programmatically
pick one jar (e.g., select the first non-original/repacked jar and rename it to
app.jar) before moving; update the mv invocation in the Dockerfile (the line
with mv target/*.jar target/app.jar) to reference the chosen single-file
selection method.
| <spring.boot.version>3.5.10</spring.boot.version> | ||
| <maven.plugin.version>3.15.0</maven.plugin.version> | ||
| <spring.boot.version>4.0.2</spring.boot.version> | ||
| <maven.plugin.version>4.0.0-beta-4</maven.plugin.version> |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
maven-compiler-plugin 4.0.0-beta-4 2026 release status
💡 Result:
org.apache.maven.plugins:maven-compiler-plugin:4.0.0-beta-4 has been released (it’s not just planned).
- Published to Maven Central: the
4.0.0-beta-4/directory is present with timestamp 2026-01-27. [1] - Apache Maven site docs exist for 4.0.0-beta-4 (plugin report page) and the official source-release download page is live. [2][3]
- Release process evidence: the ASF mail archive shows the
maven-compiler-plugin-4.0.0-beta-4tag activity (Jan 26–27, 2026) and the dev list thread for the [VOTE] release exists. [4][5]
Notes: it’s still a “beta” (pre-final 4.0.0) line, and the Maven 3 compatible line continues separately (e.g., 3.15.0 is also present). [1]
Sources: [1] (repo.maven.apache.org) [2] (maven.apache.org) [3] (maven.apache.org) [4] (mail-archive.com) [5] (mail-archive.com)
Citations:
- 1: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/
- 2: https://maven.apache.org/plugins-archives/maven-compiler-plugin-4.0.0-beta-4/?utm_source=openai
- 3: https://maven.apache.org/plugins/maven-compiler-plugin-4.x/download.cgi?utm_source=openai
- 4: https://www.mail-archive.com/commits%40maven.apache.org/msg148579.html?utm_source=openai
- 5: https://www.mail-archive.com/dev%40maven.apache.org/msg137007.html?utm_source=openai
🌐 Web query:
Apache Maven 4 release status February 2026
💡 Result:
As of February 17, 2026, Apache Maven 4 is not yet GA (generally available). The latest pre-release listed by the Maven project is Maven 4.0.0-rc-5, released November 13, 2025 (requires Java 17). [1][2]
For context, the latest Maven 3 GA release shown is 3.9.12 (released December 13, 2025). [1]
Sources
[1] Maven Releases History (last published 2026-02-17) — https://maven.apache.org/docs/history.html
[2] Apache Maven 4.0.0-rc-5 Release Notes — https://maven.apache.org/docs/4.0.0-rc-5/release-notes.html
🌐 Web query:
maven-compiler-plugin latest version 2026
💡 Result:
As of February 2026, the latest stable release of org.apache.maven.plugins:maven-compiler-plugin is 3.15.0 (released 2026‑02‑01). [1][2]
There is also a newer pre-release for Maven 4: 4.0.0-beta-4 (visible in Maven Central / listings), but it’s not a final/stable release. [2][3]
Maven config (stable):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.15.0</version>
</plugin>Sources: [1] [2] [3]
maven-compiler-plugin 4.0.0-beta-4 is a pre-release version not recommended for production.
Maven Compiler Plugin 4.0.0-beta-4 (released January 27, 2026) is a beta version designed for the upcoming Maven 4, which remains under development. As of February 2026, Maven 4 has not reached GA status (latest is 4.0.0-rc-5 from November 2025). Using beta tooling introduces build instability risks.
For production use, prefer the latest stable version 3.15.0 (released February 1, 2026), which is fully compatible with Maven 3.9.12.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@spring-wolf-example/pom.xml` at line 23, The POM sets maven.plugin.version to
the pre-release "4.0.0-beta-4" which is not recommended for production; update
the maven.plugin.version property to the stable release "3.15.0" and ensure the
maven-compiler-plugin reference uses that property (search for
maven.plugin.version and the maven-compiler-plugin plugin configuration in the
POM) so the build uses the stable compiler plugin instead of the beta.
| public void send(String text) { | ||
| KafkaDto message = new KafkaDto(text); | ||
| bridge.send("sendMessage-out-0", message); | ||
| bridge.send("kafkaV2Producer-out-0", message); |
There was a problem hiding this comment.
Critical: Binding name mismatch — producer will not route to the configured topic.
The StreamBridge.send() call uses "kafkaV2Producer-out-0" but the YAML config at spring-wolf-example/src/main/resources/application.yaml (Line 17) defines the binding as kafkaProducer-out-0. Spring Cloud Stream will not match these, so the producer will create a dynamic binding with default settings instead of using your configured destination: ${kafka.topics.simple-topic}. Messages will be sent to a topic literally named kafkaV2Producer-out-0 instead of the intended topic.
Either the code or the YAML must be updated to match:
Option A: Fix the code to match the YAML
- bridge.send("kafkaV2Producer-out-0", message);
+ bridge.send("kafkaProducer-out-0", message);Option B: Fix the YAML to match the code
In application.yaml:
- kafkaProducer-out-0:
+ kafkaV2Producer-out-0:📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| bridge.send("kafkaV2Producer-out-0", message); | |
| bridge.send("kafkaProducer-out-0", message); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@spring-wolf-example/src/main/java/com/io/example/producer/KafkaProducer.java`
at line 39, The StreamBridge binding name used in KafkaProducer
(bridge.send("kafkaV2Producer-out-0", message)) does not match the binding
defined in application.yaml (kafkaProducer-out-0), causing a dynamic binding and
wrong topic; fix by making the names identical — either change the KafkaProducer
call to bridge.send("kafkaProducer-out-0", message) so it uses the configured
destination (${kafka.topics.simple-topic}), or update the YAML binding key from
kafkaProducer-out-0 to kafkaV2Producer-out-0; ensure the StreamBridge binding
name exactly matches the binding id in application.yaml so the configured
destination is used.
…le for better compatibility
Summary by CodeRabbit
Chores
Refactor