Skip to content
Advertisement

Tag: spring-boot

How to Map Object response to another ObjectDto in java

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

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,

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

Advertisement