October 2017
Intermediate to advanced
396 pages
10h 2m
English
For the DI pattern with the construction injection, Spring provides you two basic options as the <constructor-arg> element and c-namespace introduced in Spring 3.0. c-namespace has less verbosity in the application, which is the only difference between them--you can choose any one. Let's inject the collaborating beans with the construction injection as follows:
<bean id="transferService" class="com.packt.patterninspring.chapter4. bankapp.service.TransferServiceImpl">
<constructor-arg ref="accountRepository"/>
<constructor-arg ref="transferRepository"/>
</bean> <bean id="accountRepository" class="com.packt.patterninspring.chapter4. bankapp.repository.jdbc.JdbcAccountRepository"/> <bean id="transferRepository" ...Read now
Unlock full access