212,650 questions
0
votes
0
answers
23
views
Spring Kafka Handle Commit Timeout Issue Which Using Manual ACK
We are using Spring Kafka to consume from Kafka and produce back to Kafka.
Producer side:
- Fire-and-forget
- Infinite retries
- Timeout configured to 1 hour
Consumer side:
- Ack mode: MANUAL
- Sync ...
0
votes
1
answer
101
views
Connection pool issue in hibernate 6 spring boot 3 [closed]
I recently migrated my application from Spring Boot 2 with Hibernate 5 to Spring Boot 3 with Hibernate 6 in a testing environment. Since the migration, I encounter issues during high load (overload ...
1
vote
1
answer
90
views
How do I use an Object as a filter in a native JPA query?
I have a native query that takes 4 (optional) parameters for filtering. 4 is a bit too many for readability, so I was looking into replacing it with an object. I encountered two separate problems ...
2
votes
2
answers
101
views
Spring Security JWT user becoming null
I'm implementing authentication using Spring Security with JWT.
My login and register endpoints were working correctly before adding JWT. However, after implementing JWT and adding the security filter,...
Best practices
2
votes
5
replies
131
views
Want to write online service for board games as my diploma in University
I`m big fan of board games, and when professor ask what I want to write as a diploma, I make decision fast - service for online board games.
Now I have some questions, which I don't know how to ...
1
vote
0
answers
115
views
Spring Boot 4 + Hibernate 7: Cannot persist JsonNode to PostgreSQL jsonb (InvalidDefinitionException)
I am trying to persist a JsonNode field into a PostgreSQL jsonb column using Spring Boot 4 (Hibernate 7).
Entity
import tools.jackson.databind.JsonNode;
import jakarta.persistence.*;
import org....
Best practices
0
votes
2
replies
63
views
Infinispan as Hibernate 2LC and Spring Cache
I have a question about Infinispan when its being used with Hibernate as a second level cache, while also being used as a regular cache with Spring.
Specifically, I have an Spring 7 application and I ...
-2
votes
0
answers
63
views
OpenHTMLToPDF custom TTF fonts not applied (NotoSansArabic). It falls back to default font
I'm generating a PDF using OpenHTMLToPDF (PdfRendererBuilder) in a Spring Boot app, and my custom fonts (ttf) are not being applied. What am I missing for OpenHTMLToPDF to properly apply custom TTF ...
Best practices
1
vote
3
replies
127
views
Why is field injection discouraged in Spring, while it is encouraged in Angular?
In both Spring and Angular, there are two common ways to inject dependencies:
Constructor injection
Field-style injection (@Autowired in Spring, inject() in Angular)
In Spring, constructor injection ...
1
vote
1
answer
121
views
How to disable SSL Certificate Validation in Spring RestClient?
A RestClient needs to communicate with HTTPS to a host with self-signed TLS certificate.
I have seen a similar question here on StackOverflow, Disabling SSL Certificate Validation in Spring ...
1
vote
1
answer
134
views
The import org.springframework.boot.autoconfigure.jdbc cannot be resolved
so I've been following this tutorial to build a small website: https://medium.com/@alexandre.therrien3/java-spring-tutorial-the-only-tutorial-you-will-need-to-get-started-vs-code-13413e661db5
I used ...
Best practices
0
votes
0
replies
78
views
SpringBoot solution for session metrics
We have noticed that the following Tomcat session metrics are no longer being tracked after adding the org.springframework.session:spring-session-data-redis dependency :
...
Best practices
3
votes
1
replies
70
views
Best practices for DTO mapping in jOOQ 3.20 + Kotlin Spring boot Web Apps
I recently started using jOOQ, and I absolutely love it. I really appreciate how intuitive it is writing jOOQ code feels exactly like writing raw MySQL
However, as a beginner, I’m struggling to find ...
Advice
0
votes
2
replies
95
views
Telegram Group Chat Creation Automated
I am using a Telegram bot in a Spring Boot application and I want to automate messaging for my system users.
Is it possible to:
Automatically create a group chat for each user using a Telegram bot
...
1
vote
1
answer
51
views
How to have a CorsConfigurationSource in an Autoconfiguration in Spring Boot?
I am building a company-specific Spring Boot autoconfiguration. The code looks something like this:
@AutoConfiguration
@AutoConfigureBefore(SecurityAutoConfiguration.class)
@...
0
votes
1
answer
66
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 ...
1
vote
0
answers
122
views
Injecting dependencies into custom Jackson deserializer
Since your ad-hoc deserializers are instantiated reflectively by Jackson, does it mean your custom deserializers can't do the "dependency injection" thing, declare dependencies in its ...
-1
votes
0
answers
149
views
Parsing date with optional time component [duplicate]
Related: Flaky external API, unresponsive owner
Is there an elegant way to make it more flexible so that a Date is successfully parsed regardless of whether it's yyyy-MM-dd hh:mm:ss or yyyy-MM-dd?
...
1
vote
1
answer
56
views
Backslash and Placeholder in application.yml
Given is a Spring Boot application.yml file.
host: example.com
unc-path: \\${host}\share
If unc-path is printed, the output is \${host}\share.
I expect the placeholder ${host} to be resolved. The ...
0
votes
2
answers
137
views
DockerHub: Unable to open JDBC Connection for DDL execution [Could not create connection to database server]
I am learning SpringBoot and I'm making an application that need to connect to a Springboot API. I don't have problem when running my API locally, but when I use Docker it fails to find the database.
...
2
votes
1
answer
110
views
Spring TransactionTemplate joins the Transaction of unknown origin
'org.springframework.boot' version '3.3.13'
I have a simple Task framework.
public class TaskRunner implements DelayedTaskRunner {
private static final String TASK_WORKER_THREAD_NAME_PATTERN = &...
0
votes
0
answers
100
views
Spring Session Redis not replacing Tomcat JSESSIONID (two session cookies)
I am developing a BFF (Backend For Frontend) service using Spring. For authentication, I am using an Identity Provider (Keycloak for local development). I am using the Authorization Code Flow via the ...
0
votes
1
answer
132
views
How to correctly map nested OpenID Connect (OIDC) claims to Spring Security 6 Authorities?
I am migrating a Spring Boot 3.2 application from a custom Auth server to Keycloak. In my previous setup, I used a flat list of roles in the JWT. However, Keycloak nests roles inside a realm_access ...
Advice
1
vote
0
replies
104
views
Should i stop using org.telegram telegrambots java library?
I am developing a bot using this library since last year.
Now i am interested in using colored buttons from recent update, but i noticed that telegrambots library hasn't been updated since February ...
0
votes
0
answers
122
views
Include a bean generated via an annotation to an autoconfiguration
I am working on a project with multiple Spring Boot projects. I have a one "common" project that is a dependency used by other projects. Inside that common project, I have created an @...
Advice
0
votes
2
replies
94
views
Is Spring framework 6.x compatible with Spring Security 7.x?
Is Spring framework 6.x compatible with Spring Security 7.x? I need to upgrade a servlet-based web application to the latest version of Spring Security, but due to some dependency limitations I can't ...
Advice
0
votes
0
replies
37
views
is isolation = RepeatableRead enough to prevent modification while checking a condition?
need to
read an entity
check some condition
modify the entity, if ok
how to be sure the condition still valid when 3rd point started?
@Transactional(isolation = RepeatableRead) // 1) is ...
0
votes
1
answer
68
views
Grpc client with channel whose name is derived from the stub class
In Spring-Grpc, I can configure clients declared as a beans to use named channels:
@Bean
MyServiceGrpc.SimpleBlockingStub stub(GrpcChannelFactory channels) {
return MyServiceGrpc.newBlockingStub(...
0
votes
0
answers
90
views
Populating a dropdown with a list using Thymeleaf and Spring
I'm trying to populate a dropdown of patient names from a list of strings within my controller. For some reason the dropdown is blank. I've read through several other articles that are similar to my ...
-1
votes
0
answers
59
views
Why Maven dependency isn't downloading when migrating from Spring 5 to Spring 6?
Recently, I have been trying to migrate spring 5 to 6 where javax.cache into Jakarta.cache; however, maven dependency is not downloading. If I search for this dependency then maven central is not able ...
Best practices
0
votes
1
replies
90
views
Where to put linkTo method in Spring?
I was having a discussion, where one dev-A said that linkTo should be linked directly in the controller (links that point to the controller itself), the others in the assembler, and dev-B said that he ...
-1
votes
0
answers
126
views
VectorStore.accept() exhausts HikariCP connection pool when batch ingesting with virtual threads
I am building a RAG (Retrieval-Augmented Generation) pipeline using Spring Boot 3.5, Spring AI 1.1, and pgvector. I am using Java 21 virtual threads to speed up the document ingestion process.
When I ...
2
votes
0
answers
118
views
spring.batch.jdbc.initialize-schema=always not working anymore
Although, I don't use anotation @EnableBatchProcessing, but my application not use config of spring batch in file application.yml to create schema of metadata's spring batch. How can I fix it?
The ...
3
votes
0
answers
109
views
Spring Boot ConfigurationPropertiesBinding for ImmutableMap
I'm trying to add support for @ConfigurationProperties records to use Guava's immutable types directly. I already have ImmutableSet and ImmutableList working via a Converter<List<?>, ...
Advice
0
votes
5
replies
82
views
Any product to show ROI on code refactoring or improvements
We have a very large java code base and we are looking for some tools which show technical debt and also shows return of investment in terms of time and money on resolving those issues. Please suggest....
0
votes
0
answers
78
views
Spring-core 7 does not support ExceptionCauseClassifierRetryPolicy
How to specify different retry policy for different exceptions in Spring-core 7 with Spring-rabbit-4.0.x and Spring-retry-2.0.12.
Something like below was possible in Spring-core 6 and below.
final ...
Tooling
0
votes
0
replies
99
views
Spring boot structured logging issue
Current spring implementation of structured logging with ECS format creates object "service" with fields:
name, version, environment, node
I would like to add field "id" to the ...
Best practices
0
votes
1
replies
127
views
Is it safe to reuse UserDetails from SecurityContext instead of querying the database again?
I am implementing JWT authentication with Spring Security. In this filter I validate the JWT, extract the email, and then load the user using UserDetailsService.
@Component
@RequiredArgsConstructor
...
0
votes
2
answers
113
views
MongoDb mongoTemplate for multiple databases
I have 2 databases:
test: contains a collection called people which holds documents representing the Person and Author class
test2: contains a collection called somethingElse which holds documents ...
0
votes
1
answer
153
views
@WebMvcTest behaviour related to security is different in Spring Boot 4.x compared to Spring Boot 3.x
Updated the question with my observations.
I am trying to understand Spring Security and i am stuck when implementing tests with @WebMvcTest.
I have a Spring Boot 4.0.3 project with spring-boot-...
Advice
0
votes
4
replies
100
views
Design billing system microservices communication
I have the following design for billing platform:
I'm facing the following question for to implementing the communication between microservices.
Microservice 1 is used to configure users, billing ...
0
votes
1
answer
99
views
How to disable security on tests annotated with @SpringBootTest?
I am trying to understand Spring Security and i am stuck when implementing the integration test.
I am using Spring Boot 4.0.3 with spring-boot-starter-webmvc, spring-boot-starter-webmvc-test, spring-...
0
votes
0
answers
88
views
@Pattern and @NotBlank on password field still triggered even when password is null, validation groups cause MapStruct mapping issues
I have a PATCH endpoint for updating user details. My UserRequest record has @Pattern and @NotBlank on the password field. I am facing two problems, one before using validation groups and one after.
...
1
vote
2
answers
115
views
What is the difference between transaction isolation levels and optimistic/pessimistic concurrency control?
I’m currently learning the basics of database transactions, and I’ve started studying concurrency control. However, I’m struggling to clearly understand the difference between transaction isolation ...
Best practices
0
votes
6
replies
165
views
Should I implement UserDetails directly in my User entity or create a separate UserPrincipal class in Spring Security?
I am building a Spring Boot application with Spring Security and JPA. I have seen two approaches for implementing UserDetails and I am confused about which one to use and why.
Approach 1:
@Entity
@...
3
votes
1
answer
131
views
Parallel Spring Batch jobs mixing up data
I am trying to run a separate instance of a Spring Batch job for every file, up to 20 at a time. For some reason, the job is being launched with the same parameters multiple times (same filename + ...
3
votes
2
answers
158
views
How to call a Spring @Service method before static initialization (before Spring context is fully loaded)?
I have a Spring application where I need to initialize a nodeId very early during application startup.
The problem is:
nodeId is used inside static blocks of some classes.
One of those classes is ...
3
votes
1
answer
120
views
Testcontainer in a Spring Boot test starts automatically without explicit code or annotation to start
I am playing with Testcontainers and all the different approaches to use within a Spring Boot application. I am facing some strange issue. My tests should not be passing but it does and I don't ...
4
votes
0
answers
75
views
Spring @RestClientTest
I'm using HTTP service groups improting them by @ImportHttpServices. I wrote a test annotated with @RestClientTest. I was checking a number of mock servers using MockServerRestClientCustomizer....
Advice
2
votes
4
replies
94
views
What's the difference between server.servlet.session.timeout, server.servlet.session.max-age and spring.session.timeout?
I followed this tutorial to get my authentication session up and running. However, I am unsure of the differences between spring.session.timeout, server.servlet.session.timeout and server.servlet....