I am trying to make SqsListener work but I can't with Spring Boot 3, it simply doesn't receive anything. When I change Spring Boot version back to 2.X everything's work perfectly.
I am using 2.4.2 version of Spring cloud:
...
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-starter-aws-messaging</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-aws-dependencies</artifactId>
<version>2.4.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Can you please point me to the correct version of spring cloud?
Would I need to use milestone version for that?
It doesn't work as version 2.4.2 of spring-cloud-starter-aws-messaging relies on spring.factories for Spring Boot autoconfiguration, but the support for that has been removed in Spring Boot 3.0.0. See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#auto-configuration-files.
You can enable the auto configuration by creating the following file
src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
# content
io.awspring.cloud.autoconfigure.messaging.SqsAutoConfiguration
But, it probably won't work anyway as spring-cloud-aws also relies on classes from Spring Messaging that were deprecated and removed in Spring 6 (which is used in Spring Boot 3), specifically org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver.
You'll have to wait for Spring Cloud AWS to support Spring Boot 3. They are working on Spring Cloud AWS 3.0.0, but I don't think it has a release date yet. https://github.com/awspring/spring-cloud-aws
Related
I've been working with spring boot 2.7 and its tomcat server. Today, I'm trying out spring 3 with webflux and netty. As always I want to add the prometheus endpoint but I can't seem to make it work. Here's what I did:
I added the following dependencies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<!-- Required for the prometheus actuator endpoint -->
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
I have done the following configuration:
management:
endpoint:
metrics.enabled: true
prometheus.enabled: true
endpoints.web:
# Removing /actuator from all paths
base-path: /
path-mapping:
prometheus: metrics
exposure.include: health,prometheus
But whenever I call /metrics that usually works on all my other projects I get a 404. I've tried removing all the specificities like the path-mapping or the base-path change to no avail.
I'm kinda stuck at this point.
What am I missing here?
I have a Spring MVC project which does NOT USE spring-boot.
Im trying to use Jackson2ObjectMapperBuilderCustomizer in my appConfig class to configure a default date format.
I have these two dependencies in already but I'm still getting an error on the ObjectMapper? I am using spring version 4. All the examples for using the Jackson2ObjectMapperBuilderCustomizer are using spring boot which seems to not need need a dependency
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>`
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.8</version>
</dependency>`
The class is only part of Spring Boot dependencies. If you are determined to not use any Spring Boot dependencies, you will have to look for alternatives, otherwise you can use the following:
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-autoconfigure -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>1.2.2.RELEASE</version>
</dependency>
Add jackson-datatype-jsr310 dependency . its an alternative for non spring boot projects.
https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.10.1
I am trying to migrate from spring boot 1.5 tio 2.0 and faced problem: I changed version of spring-cloud-netflix-core from 1.3.4.RELEASE to 2.0.1.RELEASE:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-core</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
Unfortunately, feign library imports failed:
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.feign.FeignAutoConfiguration;
import org.springframework.cloud.netflix.feign.FeignClient;
There is no library .feign in new 2.0.1 version. What should I use instead? (connot leave old cloud version because of conflict with spring boot autoconfiguration)
Since the 2.x release Spring Cloud moved the netflix feign classes to their own project.
https://github.com/spring-cloud/spring-cloud-openfeign
You need to update your re-import with the correct package
org.springframework.cloud.openfeign
You need to import feign as an independent dependency starting from 2.X release:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
I'd like to use spring boot specific BOM for my non-boot spring project. Is it acceptable to include spring-boot-dependencies or platform-bom and what's better?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>...</version>
<type>pom</type>
<scope>import</scope>
</dependency>
or
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>...</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Thanks.
Both are valid approaches.
To quote the Spring IO Platform documentation :
Spring IO Platform builds on top of Spring Boot
So, they provide what you search for a non spring boot application : a set of consistent dependencies and some specific beans provided by Spring Boot.
Now, personally, I would chose org.springframework.boot:spring-boot-dependencies as Spring Boot is mature, have an important and active community and is often updated.
See the spring-boot github.
It is not the case of the spring-io/platform.
I'm creating an application using Spring Boot and also Elastic-Search. Spring application part is working. And also when I start Elastic server, it's also running well. No issues at all. I can test it via POSTMAN and also CURL. Adding and also searching works well.
But when I run the application, i'm getting following issues.
This is the issue i'm getting in the IDE. (which means from my java application)
org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{127.0.0.1}{127.0.0.1:9300}]
And this is the issue i'm getting from the Elasctic server on my local system.
java.lang.IllegalStateException: Received message from unsupported version: [2.0.0] minimal compatible version is: [5.0.0]
These are the libraries I'm using.
Spring Boot 1.5.1.RELEASE
Spring Boot Starter Data Elasticsearch 1.5.1.RELEASE
Spring Data Elasticsearch 2.10.RELEASE
Elastic Search 5.0
I think this is a issue with Elastic and above library version mismatch.
I'm new to Elastic and also Spring. The version issue is here.
https://github.com/spring-projects/spring-data-elasticsearch/wiki/Spring-Data-Elasticsearch---Spring-Boot---version-matrix
And also here is my pom.xml. If I need to update any library, can anyone tell me what's that ? And also tell me how to update those libraries ? Can I update them without changing to my source code ?
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<artifactId>springboot-springdata-elasticsearch-example</artifactId>
<packaging>jar</packaging>
<url>https://www.mkyong.com</url>
<version>1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Runtime, for Embedded Elasticsearch,
comment this if connect to external elastic search server-->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Package as an executable jar/war -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
In this pom.xml , I can't find all the dependencies too.
According to the versions matrix that you provided, the spring boot version that you're using is not compatible with ElasticSearch 5.x instances. So, i think you have 3 options:
If you really need to work with SpringBoot 1.5.1 using ElasticSearch 5.0, you should add the maven dependencies related to ElasticSearch 5.0 and implement your own DAO service.
You can try to downgrade your ElasticSearch version to 2.4 in order to make it compatible with your current spring boot version.
Maybe you can try to use the recent spring boot version (1.5.4) because arcording to the spring-data-elasticsearch project (https://github.com/spring-projects/spring-data-elasticsearch/), the last version supports ElasticSearch 5.x, so probably it could be the easiest way.
Please let me know if any of options above was useful for you.