This is the same happen to me just now. I start a new Kafka stream app with the maven. The command is here,
$ mvn archetype:generate \
-DarchetypeGroupId=org.apache.kafka \
-DarchetypeArtifactId=streams-quickstart-java \
-DarchetypeVersion=2.0.0 \
-DgroupId=streams.examples \
-DartifactId=streams.examples \
-Dversion=0.1 \
-Dpackage=myapps
I get a code snippet like this auto-generated,
builder.stream("streams-plaintext-input")
.flatMapValues(value -> Arrays.asList(value.split("\\W+")))
.to("streams-linesplit-output");
This shows an error Cannot Resolve Method split(java.lang.String)
. Obviously, the split
method belongs to the String
class and hence, I had it to chnage as following,
builder.stream("streams-plaintext-input")
.flatMapValues(value -> Arrays.asList(value.toString().split("\\W+")))
.to("streams-linesplit-output");
I'm curious why the maven archetypes provide a wrong code snippet. I'm talking about the Java 8