58,754 questions
Score of 0
0 answers
63 views
Failed Test of POST good working method in controller with HttpServletRequest argument
the application works correctly and the controller processes requests without any problems without throwing 404 - it returns 202 and processes anachronistic task, but despite all this I cannot ...
Score of 1
0 answers
127 views
ErrorPageRegistrarBeanPostProcessor bean overriding error
I created a MyApplication.java file following the tutorial under the URL linked below using maven.
https://docs.spring.io/spring-boot/tutorial/first-application/index.html
import org.springframework....
Advice
1
vote
2
replies
155
views
Difference between Spring Initializr and Maven Repository
I am moving from standalone Java applications to building Spring Boot projects, and I am confused about the mechanical overlap between Spring Initializr (start.spring.io) and the Maven Central ...
Score of 3
0 answers
110 views
What is the alternative to UrlPathHelper.setAlwaysUseFullPath(true) after Spring 7 using PathPatternParser?
Spring 7 is deprecating the use of UrlPathHelper in PathMatchConfigurer. I'm using it with setAlwaysUseFullPath(true) in WebMvcConfigurer.configurePathMatch because I have several DispatcherServlets ...
Score of 1
1 answer
92 views
Is there a way to log the full request and response in Spring RestClient on error?
I've been stuck on this task for quite a while. It seems simple, whenever an error happens during a RestClient request, I want to log both the request and response data + body for debugging purposes.
...
Score of -1
1 answer
70 views
Asserting on generic response body
How do you assert on a JSON list of objects with MockMvcTester?
I want to cleanly map it to List<MyDto> and assert on that list.
import com.example.em_card_service.data.dto.response....
Best practices
0
votes
1
replies
115
views
Cleanly map DB constraint violations, no mimicking constraints in app
user.name has a UNIQUE constraint on the DB (PG).
I catch DataIntegrityViolationException in my global handler:
@ExceptionHandler(DataIntegrityViolationException.class)
public ResponseEntity&...
Best practices
0
votes
3
replies
148
views
Understanding older Spring Boot REST API style using @Controller + @ResponseBody
I recently joined a company project built using Spring Boot 2.x.
The project exposes REST APIs, but instead of modern annotations like:
@RestController
@PostMapping
the code uses older style patterns ...
Advice
0
votes
1
replies
103
views
Map custom exception to error response code, keep default ErrorAttributes
My goal is to handle a custom exception.
I want to keep the default error response shape (properties) + error message. ProblemDetail consists of different properties. It's because I want to have the ...
Best practices
1
vote
1
replies
86
views
Map unavailable authorization server to 503
Is this how I am expected to map "authorization server's down" to 503?
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
....
Advice
0
votes
0
replies
104
views
Modify the StatusHandlers in DefaultRestClientBuilder?
Why isn't it possible to modify the StatusHandler in DefaultRestClientBuilder in a similar way to DefaultRestClientBuilder.requestInterceptors(Consumer<List<ClientHttpRequestInterceptor>> ...
Score of 1
1 answer
125 views
Spring Boot Controllers not called
We are upgrading to Spring Boot 3.5.5 so some code is historically grown.
We have a central portal application where users can login. It provides different login mechanisms depending on the specific ...
Best practices
1
vote
1
replies
138
views
Configuring Spring Boot 3 (Spring MVC & Spring Security 7) for CORS public access (with credentials)
There are lots of good examples for how to configure Spring Boot for CORS online, but it seems to be very hard to find anything with an intersection of:
Using the APIs in Spring Boot 3 rather than ...
Score of 0
1 answer
143 views
Spring Boot OAuth2ResourceServer Excluding Paths (Cloudflare Turnstile)
I have a Spring Boot REST API written in Kotlin using Keycloak with Spring Security for authentication and authorization. I want to expose one endpoint publicly but protect it with Cloudflare ...
Score of 2
0 answers
164 views
Hibernate LEFT JOIN FETCH returns empty PersistentBag in Spring @Transactional integration test
Hibernate LEFT JOIN FETCH returns empty PersistentBag in Spring @Transactional integration test
Problem
When using @Transactional on a Spring Boot integration test class, Hibernate's
LEFT JOIN FETCH ...