150,388 questions
Best practices
0
votes
4
replies
63
views
How to cross validate properties in Spring Boot?
My application has the following properties
employeeEngine.callLegacy=true
employeeEngine.callNewApi=true
I want to make it possible to call either only the legacy service, or the new api endpoint (...
0
votes
0
answers
33
views
Activating Hibernate Batching causes "HHH100503: On release of batch it still contained JDBC statements" log for every asynchronous call
Baseline Situation
I've got a spring boot application that uses jpa, hibernate und a mysql8 database.
At some points the application has to persist a large number of small entities where the database ...
1
vote
0
answers
42
views
AbstractMethodError on XSSFColor.getStoredRGB() when using custom fill color with Poiji 4.1.1 on classpath
Problem
I'm trying to set a custom hex color (#00458D) on Excel header cells using Apache POI in a Spring Boot project. The only approach that works without throwing an error is using an indexed color:...
0
votes
0
answers
51
views
Getting error log "Deadlock found when trying to get lock; try restarting transaction" despite handling with spring retry
I'm working on a spring boot project utilizing jpa and hibernate with a mysql database. Recently I did some refactoring and changed a OneToMany collection mapping, that was unidirectionally mapped by ...
3
votes
2
answers
152
views
Error while sending mail in Java (Spring Boot)
I am trying to send email using Spring Boot with Gmail SMTP, but I am getting the following exception:
org.springframework.mail.MailSendException: Mail server connection failed.
Failed messages: ...
-4
votes
0
answers
156
views
Deterministic TextEncryptor
I want this encryptor to return the same value for the same input. It makes sense for card numbers. Otherwise, you wouldn't be able to enforce the UNIQUE constraint (and would lose the ability to ...
-1
votes
1
answer
51
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
107
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
117
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
85
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 ...
Advice
0
votes
0
replies
39
views
getKeyedResultList, KeyedPage class construction and persistence
I would like to know if keyset pagination is intended to be used in an API. The current implementation for it is not conducive to being used across multiple requests.
For reference, this is how we are ...
Best practices
1
vote
1
replies
74
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
....
Best practices
1
vote
1
replies
72
views
integrate dynamically with multiple external institutions
I’m building a Java Spring Boot system that needs to integrate dynamically with multiple external institutions (banks/payment providers/etc.).
Each institution can have:
Different protocol types (...
Advice
0
votes
2
replies
89
views
Maven cannot resolve spring-boot-starter-data-jpa-test dependency in Spring Boot 4.0.6
I've been making a course of Spring boot fundamentals, with spring 4.0.6 and java 25, but I have some errors with the dependency, I changed the version for 3.5.0, I changed the dependency for another, ...
Advice
0
votes
2
replies
118
views
Create root admin user
How do I create the initial admin user in my Spring Boot 4 application?
At first, my signup endpoint simply accepted an array of roles in the DTO. But, I concluded, it's a bad idea.
Then, I ...