私は春の初心者で、以下の概念を理解しようとしています。春のオートワイヤーの基礎
accountDAO
がAccountService
の依存関係であるとします。
シナリオ1:
<bean id="accServiceRef" class="com.service.AccountService">
<property name="accountDAO " ref="accDAORef"/>
</bean>
<bean id="accDAORef" class="com.dao.AccountDAO"/>
シナリオ2:AccountService
クラスで
<bean id="accServiceRef" class="com.service.AccountService" autowire="byName"/>
<bean id="accDAORef" class="com.dao.AccountDAO"/>
:2番目のシナリオで
public class AccountService {
AccountDAO accountDAO;
....
....
}
、どのように依存関係が注入されますか?私たちが名前によってautowiredであると言うとき、それはいかに正確に行われていますか。依存関係を突きつけているときに一致する名前はどれですか?
ありがとうございます!
[Spring @Autowired usage](https://stackoverflow.com/questions/19414734/understanding-spring-autowired-usage)の可能な複製 – tkruse