Loading...

Top Questions

18
votes
1
answers
656
Spring Data JPA Repository returns null instead of empty list

I have a JPA Repository method that should return a List, but it returns null instead of an empty list when no results are found. ```java public inte...

jpa_wizard
980 • 2 days ago
29
votes
1
answers
950
How to write unit tests for Spring Boot controllers with WebMvcTest?

I want to write unit tests for my REST controllers in Spring Boot. I've heard about @WebMvcTest but I'm not sure how to use it properly. How do I: 1....

micro_king
1.2k • 3 days ago
45
votes
1
answers
1,250
What is the difference between Spring and Spring Boot?

I am new to Java development and I keep hearing about Spring and Spring Boot. What exactly is the difference between them? I understand that Spring i...

spring_guru
1.5k • 3 days ago
44
votes
1
answers
1,680
Best way to handle exceptions globally in Spring Boot REST API?

I want to handle all exceptions in one place in my Spring Boot application instead of using try-catch in every controller method. What's the best pra...

java_master
2.3k • 4 days ago
32
votes
1
answers
890
How do I enable and secure Spring Boot Actuator endpoints?

I want to use Spring Boot Actuator to monitor my application in production. I added the dependency but all endpoints are exposed. How do I: 1. Enable...

boot_dev
850 • 4 days ago
41
votes
1
answers
1,120
How to validate request body in Spring Boot REST API?

I'm building a REST API and need to validate the request body. I have a UserDTO class: ```java public class UserDTO { private String email; p...

java_master
2.3k • 5 days ago
27
votes
1
answers
780
How to use Spring Boot profiles for different environments?

I need to configure different database settings for dev, test, and production environments in my Spring Boot application. What's the best way to use ...

micro_king
1.2k • 6 days ago
56
votes
1
answers
1,801
LazyInitializationException in Spring Boot JPA - How to fix?

I'm getting this error when trying to access a collection after fetching an entity: ``` org.hibernate.LazyInitializationException: failed to lazily i...

jpa_wizard
980 • 6 days ago
52
votes
1
answers
1,450
How to enable CORS in Spring Boot for my React frontend?

I have a Spring Boot backend running on localhost:8080 and a React frontend on localhost:3000. When I try to make API calls from React, I get: ``` Ac...

spring_guru
1.5k • 1 week ago
67
votes
1
answers
2,101
@Autowired vs Constructor Injection - which is better in Spring Boot?

I've seen two ways to inject dependencies in Spring Boot: ```java // Field Injection @Autowired private UserService userService; // Constructor Inje...

boot_dev
850 • 1 week ago
Have a question?

Get help from thousands of developers

Ask Question
Top Contributors
Community Stats
Questions 10
Answers 0
Users 0
Tags 0