问题描述
- 求下列代码详解,谢谢各位大神了,跪求
-
<bean id=""chezhuxinxiDao"" class=""com.sysgrrj.module.Chezhuxinxi.dao.ChezhuxinxiDao""> <property name=""sessionFactory""> <ref bean=""sessionFactory""/> </property> </bean> <bean name=""chezhuxinxiBean"" class=""com.sysgrrj.module.Chezhuxinxi.action.ChezhuxinxiAction"" scope=""prototype""> <property name=""dao""> <ref bean=""chezhuxinxiDao""/> </property> <property name=""coreService""> <ref bean=""coreService""/> </property> </bean>
解决方案
定义了两个bean,以及它们依赖的service和factory
解决方案二:
<bean name=""chezhuxinxiBean"" class=""com.sysgrrj.module.Chezhuxinxi.action.ChezhuxinxiAction"" scope=""prototype""> 定义的bean对应你的方法类ChezhuxinxiAction <property name=""dao""> <ref bean=""chezhuxinxiDao""/>在ChezhuxinxiAction中使用的dao注入 </property> <property name=""coreService""> <ref bean=""coreService""/> </property></bean>
解决方案三:
应该dao、service、action各一个bean配置
解决方案四:
spring 的依赖注入
时间: 2025-01-30 22:29:13