Override spring kakfka version - spring

How to include the particular version of spring kafka. Kafka version dependency is 2.5.14 imported by the starter parent. But I want to override it with 2.6.10 version
How can I do it?
This is my Spring Boot starter
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.12.RELEASE</version>
</parent>
Kafka version dependency is 2.5.14 .
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>

in your project pom.xml file override spring-kafka.version property value to give desired version.
And if you want to override kafka libraries version in the same way you can override kafka.version property value.
<properties>
<spring-kafka.version><!-- desired spring-kafka version--></spring-kafka.version>
<kafka.version><!-- desired kafka version--></kafka.version>
</properties>

Related

how to import spring-boot-starter-data-solr in spring boot 2.6.4

I'm studying using solr in springboot, I try the program in a book, the spring-boot-starter-parent version is 2.1.2.RELEASE in the book:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
while my spring-boot-starter-parent version is 2.6.4:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
and I add the solr dependency in pom.xml like this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-solr</artifactId>
</dependency>
but the pom.xml shows error: The version cannot be empty, so I go to https://mvnrepository.com/ and find the latest spring-boot-starter-data-solr version is 2.4.13, so I add the solr dependcy like this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-solr</artifactId>
<version>2.4.13</version>
</dependency>
the pom.xml has no error now, but the java program which import solr still not work, such as:
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
it cannot find any class about solr. I also try to download the spring-boot-starter-data-solr jar in https://mvnrepository.com/, and I import it locally, but I only find a META-INF document in the spring-boot-starter-data-solr jar downloaded, it doesn't have any classes
so how should I use solr in springboot?
The Spring Data for Apache Solr project has been discontinued. As a result, it was removed from the Spring Data release train in its 2021.0.0 release and from Spring Boot in its 2.5.0 release.
If you are using Solr directly, rather than via Spring Data, you can continue to do so. You will have to declare your Solr dependencies directly rather than relying on the Data Solr starter and you will have to configure Solr in your application rather than relying on Spring Boot's auto-configuration to do so.
solr-solrj is probably the updated alternative to the not updated spring-data-solr.

spring-boot-starter-parent AND spring version

I'm developing a Java spring web service application. The application has a maven multi module layout, containing a webapp module - and a client module with a retrofit client.
I want to use the spring boot starter to manage my dependencies - and thus my webapp has the entry:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
</parent>
My client needs some Spring types - and this dependency would suufice:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.1.4.RELEASE</version>
</dependency>
Is there anyway to couple these versions?
You can use Spring Boot without the parent.
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-maven-without-a-parent
So you could add the dependency management to your own parent POM and both modules can use that as parent.

Spring Boot 2.0.5 still using Spring version 4.3.8.RELEASE

I am using Spring boot version 2.0.5 in an IntelliJIdea project. Here is my maven.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath />
<!-- lookup parent from repository -->
</parent>
I verified that it was using Spring version 4.3.8 even though, Springboot's documentation clearly says that Springboot 2.0.X uses Spring version `5.0.X.
After this I overrode the <spring.version> property in the POM file, as shown below:
<properties>
<spring.version>5.1.2.RELEASE</spring.version>
</properties>
Still, the version of Spring my project uses is 4.3.8!
System.out.println("version: " + SpringVersion.getVersion()); . outputs 4.3.8.RELEASE.
Can anyone help me understand how to actually update Springboot's version of the Spring framework used?

How to use Spring Kafka 2.1.0.RELEASE

It is really great to grab the Spring Kafka 2.1.0.RELEASE to unleash the power of the kafka client 1.0.0. However when I tried to use it spring boot 1.5.9.RELEASE , which is the latest release version of boot it throws an exception .
java.lang.NoSuchMethodError: org.springframework.util.Assert.state(ZLjava/util/function/Supplier;)V
at org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter.determineInferredType(MessagingMessageListenerAdapter.java:396) ~[spring-kafka-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter.<init>(MessagingMessageListenerAdapter.java:100) ~[spring-kafka-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter.<init>(RecordMessagingMessageListenerAdapter.java:61) ~[spring-kafka-2.1.0.RELEASE.jar:2.1.0.RELEASE]
My POM file is
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath />
</parent>
...
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<version>2.1.0.RELEASE</version>
<scope>test</scope>
</dependency>
.....
How should I be able to use Spring Kafka 2.1.0.RELEASE with a spring boot project .
Is there any release of boot that support spring 5 yet.
Thanks
Joy
For the Answer
Click disqus.com
This is beautifully explained by Francisco , I put up the link as it might help others as well!
I am using Spring boot 1.5.9.RELEASE and spring-kafka:2.1.0.RELEASE have faced similar but not this exception, I would suggest cleaning and building application again to clear maven cache and dependencies.

Spring Boot with Spring HATEOAS Maven conflicts

It seems when I add the dependency for the spring-hateoas
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
<version>0.13.0.RELEASE</version>
The Class below is no longer available on the classpath
org.springframework.web.bind.annotation.RestController;
I have tried to exclude various dependencies for the spring-hateoas but the APP no longer runs.
Has anyone had any luck running spring-hateoas within spring boot.
Absolutely no problem whatsoever. The #RestController annotation is still available and you shouldn't need to do any exclusion.
In case it helps, I'm currently using version 1.0.2 of Spring Boot:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.2.RELEASE</version>
</parent>
spring-boot-starter-web provides the #RestController:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
I don't define an explicit version for spring-hateoas in my pom.xml, but my build is pulling in 0.9.0.RELEASE:
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
</dependency>
As a side note, I can see from the Eclipse POM editor, that Spring HATEOAS is defining dependencies on Spring 3.2.7. However the spring-boot-starter-parent project manages the versions up to 4.0.3. Can you see what version of Spring you are getting? Have you perhaps not used the spring-boot-parent as a parent project?

Resources