I want to connect to mongoDB Atlas in a spring boot project, but always Exceptions are thrown. If I use Java without spring boot, everything works fine. The following test project reproduces the errors. The pom.xml: The Main-class: And the configuration for mongoDB: The uri for mongoDB is stored in applicatio…
Tag: spring-boot
what will happen if we didn’t define @Bean under @Configuration class in spring boot
so usually when we write a class and add @Configuration to the class, we will define bean in that class for example: @Configuration public class AppConfig { @Bean public DemoClass service() …
How to handle “org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error” in Spring?
I’m adding an API to an existing Spring Boot project using @RestController. My Spring Boot experience is: This is my first time using it. The RestController works fine when I make a properly formed request but throws an error if the request is not correct (this is what I would expect). However, I can…
Problems with aggregate SQL functions in Spring Boot application
I’m working on a website in a Spring Bootwhich is connected to a MySQL db. In the db i have two tables: Player and Match and i created a query that should return me a list of players with count of matches they already played. The problem is that typed aggregate function count(M) doesn’t and I don&…
Spring autherization http security redirection, session issue
I am using Spring http security(Enablewebsecurity) to manage sessions. But the issue I am facing is, whenever I start the application, the app is opening always home page instead of going to login page. The requirement here is if session is out, need to go login page. Also session needs to time out for 30minu…
Keycloak java.lang.NoClassDefFoundError: java/security/acl/Group using Springboot
So we are building a Springboot back-end with Keycloak integration. But we get the following error when running the back-end on a docker swarm service: I tried it with JDK 8 and JDK 11 since the following post implies that the wrong JDK can cause a problem: Stackoverflow post. It still gives this error. The f…
Issue when mapping Collection of List using ModelMapper in Spring Boot
I have a Project domain which I want to map on a ProjectDTO using modelmapper. The Project domain contains a List of Locations. In the DTO, I don’t want the Location domains, just the ids of the locations. So I followed the tutorial of Link and created a custom converter: Then, I created the PropertyMap…
Connect to multiple Kafka Cluster’s using spring Kafka
I have a spring boot application that consumes messages from a topic(say topic1) in a Kafka cluster. This is how my code looks like currently. Now I want to start consuming from a different topic in another Kafka cluster. One way is to create another bean for this. But is there a better way to do this? Answer…
Library with Spring AutoConfiguration: spring.factories and what else?
We intend to develop a library with Spring Components that all of our Spring Applications should have, like Beans that connect to our monitoring, administration and ochestration services. The idea was, to make use of Springs’ “AutoConfiguration”-mechanism. For a Starter I wrote a class com.m…
Setting GCP environment variable in Spring boot with vs code
I’m trying to set up GOOGLE_APPLICATION_CREDENTIALS but keep getting this error java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing …