I have a controller with several endpoints. Every endpoint is mapped to a service which could return 200 or throw an exception, that is then handled and will return the correct error message. For example, if a user is not found I throw a UserNotFoundException, which is then caught in the ControllerAdvisor tha…
Tag: spring-boot
Why users are not displayed from the database?
I can’t get a list of users from the database.I am assuming userService.allUsers () = null. But why? I have no idea. Since there are users in the database. Please tell me what is wrong with my code? It does not give me any errors in the logs. AdminController Class UserService ForAdmin.html I do not even…
JPA and Spring Boot : integer from DB (H2) doesn’t get mapped to boolean as expected
I am refactoring part of an Spring Boot 2.3.1 application, in which previous developers have used Integer type (with values 0 or 1) instead of boolean a bit everywhere in the code. But I am noticing something I didn’t expect : I’ve also changed the field type in the entity class, and when loading …
Use public key fingerprint in Java Spring Boot application to solve “The authenticity of host ‘xxxx’ can’t be established”
I have a Java Spring Boot application which is using the spring-integration-sftp dependency to connect to an SFTP server. I get an error The authenticity of host ‘xxxx’ can’t be established and I know this can easily be rid of by setting the sftpSessionFactory.setAllowUnknownKeys(true), but …
Spring data redis – How to use hashOperation’s scan method to get keys or values based on pattern?
I have never worked on Redis and Spring boot. I want to use Redis as a cache. I have been using hashOperations for get/set operations. I have configured the RedisTemplate to stop weird hashes from getting prepended to a key. I have a class called Post which I am caching. A user can create multiple posts. The …
How to resolve Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
I am getting the following error when I am trying to run my test case for a simple springboot application. Not sure what am I missing. Any help would be highly appreciated. Controller.java PersonService.java PersonServiceImplementation.java ControllerTest.java Here, the BASE_REQUEST is a json string which act…
Getting NPE on ControllerTest using SpringBoot WebFluxTest and JUnit4
I’ve this project structure: And I am trying to test a dummy method on the Controller. The funcionality is very simple. You send a String by POST and is returned with a + “123” CustomerServiceImpl.java CustomerController.java And the controller test class: CustomerControllerTest.java Then, w…
@JsonProperty not working after springboot upgrade
I recently upgraded my application from Spring Boot 1.5.3 to Spring Boot 2.3.5. One of the feature on UI started breaking and I found while debugging that the json response to UI had changed Original response: New response: having underscores (_) in attribute names It seems that the @JsonProperty is not worki…
Does Lombok’s @AllArgsConstructor Autowire the fields in spring boot automatically?
I am following a YouTube tutorial to build a spring boot application. The person used lombok and so he didn’t had the @Autowired annotation on any field of the class and his code works fine. However when I tried the same, the console shows the service is null. Appropriate code and Output Screenshot atta…
Conversion Error on LocalDate attribute when form-data request is sent to a Spring boot application
I send a form-data request from the Postman to a spring application. The LocalDate field in the Spring application as a text field from the form-data. I got a Conversion Error. Field error in object ‘vehicleDto’ on field ‘leasingExpiry’: rejected value [2021-01-01]; codes [typeMismatch…