Backend Development Spring Boot Subjective
Oct 03, 2025

What is dependency injection in Spring Boot? Provide example.

Detailed Explanation
Dependency injection provides dependencies to a class rather than creating them. Example:\n\n@Service\npublic class UserService {\n @Autowired\n private UserRepository userRepository;\n \n public User findById(Long id) {\n return userRepository.findById(id);\n }\n}
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback