Bird
0
0

Identify the error in this Spring Boot repository interface following enterprise patterns:

medium📝 Debug Q14 of 15
Spring Boot - Advanced Patterns
Identify the error in this Spring Boot repository interface following enterprise patterns:
public interface UserRepository {
    User findById(int id);
}
AMissing @Repository annotation
BUser class must be final
CInterface should extend JpaRepository or similar
DMethod name should be getUserById
Step-by-Step Solution
Solution:
  1. Step 1: Check interface declaration for Spring Data JPA

    Repository interfaces should extend JpaRepository or a similar interface to work properly.
  2. Step 2: Verify other options

    @Repository annotation is optional if extending JpaRepository; method name is fine; User class finality is unrelated.
  3. Final Answer:

    Interface should extend JpaRepository or similar -> Option C
  4. Quick Check:

    Repository interface must extend JpaRepository [OK]
Quick Trick: Repositories extend JpaRepository for Spring Data support [OK]
Common Mistakes:
  • Forgetting to extend JpaRepository
  • Thinking @Repository is always required
  • Changing method names unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes