IOC装配Bean
(1)Spring框架Bean实例化的方式提供了三种方式实例化Bean
下面先写这三种方法的applicationContext.xml配置文件:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://pamy">杭州归谷</prop> <prop key="pnum">200</prop> </props> </property> </bean> <!-- end Bean的依赖注入============ --> <import resource="classpath:bean1.xml"/> <import resource="classpath:bean2.xml"/> <!-- 这里导入是指如果在src下还有其它的beans.xml我们可以这样去调用 --> </beans>有关applicationContext.xml这个配置文件里的内容一定要看懂,我写的还是比较基础和全面的。
有关命名空间p的使用我这里在解释下:
p:<属性名>="xxx" 引入常量值
p:<属性名>-ref="xxx" 引用其它Bean对象
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。