Using @Autowired with setter method

Here you can annotate the setter method's setAccountRepository and setTransferRepository with the @Autowired annotation. This annotation can be used with any method. There is no specific reason to use it with the setter method only. Please refer to the following code:

    public class TransferServiceImpl implements TransferService { 
      //... 
      @Autowired 
      public void setAccountRepository(AccountRepository  
accountRepository) { this.accountRepository = accountRepository; } @Autowired public void setTransferRepository(TransferRepository
transferRepository) { this.transferRepository = transferRepository; } //... }