I have to map rest template response to my DTO with different key and values. currently I am getting this json response from rest api And I want to map it into my DTO for me able to save into DB What i want is to get only same key dynamically to match with the response of api above. Currently
Tag: spring-boot
Choose Controller Bean instance by RequestMapping
I want Spring to create 2 instances of FooController. Requests to /foo should be handled by one of the instances and requests to /bar should be handled by the other instance. I want something like the …
org.mapstruct don’t work with a base class
I have 2 classes. My base class: And my other class. This class extends BaseRequest class. And When I try create a mapper to cast my AddClass to OtherClass: When I run my build I received this error: Error:(22,13) java: No property named “dateTransaction” exists in source parameter(s). Did you mean “null”? Answer MapStruct works without issues with Lombok. However,
How do you parameterize the Spring Boot Gradle plugin?
We are looking to migrate from Maven to Gradle, and have worked through most of the challenges you would expect for replacing the parent POM concept. There is one sticky point that we haven’t figured out yet. We need to specify the version of Spring Boot we are using globally, but I run into invalid build file problems with both
Solr synonym.txt adding at elasticsearch
I have already a working synonym.txt in solr. Now I want to add that same txt file at elasticseach. What can I do for it. At solr it was easy, I just keep that file in system. At elsticsearch I added …
Spring Security returns 403 instead of 401 and creates invalid Redis session cookie
I’m using Spring Security and Spring Data Redis to keep track of user sessions with custom roles and entitlements. When I try to hit a PreAuthorized endpoint without a session cookie in my browser, it should return a 401. Instead a new (invalid) session cookie is created and the endpoint returns a 403. Here’s my SecurityConfig: I’m also using MethodSecurityConfig
FreeMarker configuration conflict (Spring Boot)
I have a FreeMarker configuration: And dependencies from build.gradle: It works okay. But when I set following dependency in build.gradle: implementation ‘org.springframework.boot:spring-boot-starter-data-rest’ I’ll get an error: Seems like spring-data-rest provides configured FreeMarker too and conflict happens. @Primary and @Qualifier don’t work. What can I do? [UPDATE] Tried to add exclude to my main class: Now application can start, but FreeMarker
HTTP Basic Authentication using Spring Boot’s Java based configuration
I am trying to set up a simple Spring Boot application secured with HTTP Basic Authentication using a single user with a hard-coded password. So far, I got it working using XML based configuration. How can I achieve the same result using Java based configuration? SecurityConfig.java spring-security.xml Note: I had to use @EnableWebSecurity instead of @Configuration to work around Spring
Expecting exception during MockMVC.perform in JUnit5
This may be a repeated question. But I have gone through some 10-15 related posts and associated responses which have not resolved my issue. The issue that I am facing is as here below I have a SpringRest controller class with custom ApplicationException. I have written a Junit for my controller and here below is the snippet where I am
Jpa Enum error with Smallint type in postgres
I want to put enum in my entity. But I have an error with validation which JPA wonts smallint set as enum. How I can solve this issue. “Schema-validation: wrong column type encountered in column [status] in table [order]; found [int2 (Types#SMALLINT)], but expecting [int4 (Types#INTEGER)]”[enter image description here] Answer Add columnDefinition=”int2” at OrderStatus in your entity. Tested on spring