I am trying to understand how to use Authowire in Spring.
I saw a question here and understood how to use it.
However, isn’t spring working on interfaces?
Isn’t the UserService needs to be an interface?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, you don’t have to use interfaces but it will make you life more simple at some point in the future.
Alas, as with all predictions of the future, this assumption could be wrong. In that case, the effort to create and maintain an interface would be wasted.
Moreover, modern IDEs offer powerful refactorings to replace a specific type with an interface.