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() …
Tag: spring
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’t figure out how to give a
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 30minutes. Is there any wrong with
Unhandled IOException when instantiating ResponseException for test
Trying to create a unit test for an elastic search exception handler that uses ResponseException but having trouble setting up the object. Mocking doesn’t work as ResponseException is a final class. produces the following compilation error: Unhandled exception: java.io.IOException Any help is appreciated. Answer Typical Java trick for this case:
cURL works while accessing GitHub /search/users API but using restTemplate.exchange returns zero users
I have defined a RestTemplate backed HttpClient to call Github API to search users My method is this This method hits the URI and return [] as Items(part of response Body) while if I use the same URI with cURL it gives me four responses. I am unable to find my fault. Answer investigating with OP in the comments, we
Spring DataSource password in separate properties file causes “Failed to determine a suitable driver class”
I have the following Spring configuration Which is configured into the following class (annotations are lombok and Spring). This works just fine when all the properties are in one application.properties file. The application starts up properly. I am trying to move the password line into it’s own application-secret.properties file, and keep the other properties in the main application.properties file. I
I want to send a List(which is a member of an object) from Postman to Spring REST API
I have an object, and of its attributes is a List. I want to send this object from Postman to my service. I’m using Spring 5.2.7 (Spring MVC, not SpringBoot) and Hibernate 5.4.17 and Java 8. My problem is very similar to this one: I want to send a Postman POST request with an Array: members: [“william”, “eric”, “ryan”] This
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 to tell modelmapp to use
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 You need
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.mycorp.project.basic.startup-notification.StartupNotificationPublisher.class which, uppon “ApplicationStartedEvent” sends a Message via our favorite message broker (which for the exmample