Dejell
Dejell

Reputation: 14337

@Autowire in Spring

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?

Upvotes: 1

Views: 581

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328770

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.

Upvotes: 3

Related Questions