public class BookServiceImpl implements BookService {
private BookDao bookDao;
//提供对应的set方法
public void setBookDao(BookDao bookDao){
this.bookDao = bookDao;
}
}
? property标签:
????????ref属性注入的是引用类型对象(第一个bean标签的id),
??????? name属性是前面set方法中的参数名称。
<bean id="bookDao" class="com.spring.dao.impl.BookDaoImpl"/>
<bean id="bookService" class="com.spring.service.impl.BookServiceImpl">
<property name="bookDao" ref="bookDao"/>
</bean>
?上面是引用类型注入,
简单类型注入set方法和上面相同,配置中property标签value属性是具体值:
<bean id="bookDao" class="com.spring.dao.impl.BookDaoImpl">
<property name="databaseName" value="mysql"/>
<property name="connectionNum" value="100"/>
</bean>