日期:2014-05-17  浏览次数:20805 次

spring 注入问题?
XML code


    <!-- Dao是无状态的 是单例的 scope="singleton"
    <bean id="userDao" class="com.test.dao.impl.UserDAOImpl"
        scope="singleton">
        <property name="sessionFactory">
            <ref bean="sessionFactory" />
        </property>
    </bean>

    <bean id="userService"
        class="com.test.service.UserServiceImpl">
        <property name="userDao" ref="userDao"></property>
    </bean>
 -->
 
 
    <!--控制层-->
    <!--id="saveUserAction" 别名--><!-- scope:prototype 生产新的action-->
    
    <bean id="listUserAction"
        class="com.test.action.user.ListUserAction" scope="prototype">
        <property name="service" ref="userService"></property>
    </bean>




现在不定义接口了,就是那个 userDao和userService 没了,注释部分怎么改写啊??

------解决方案--------------------
不定义接口?? 怎么依赖注入?? 在我的印象中好像是一定要的?? 要不就没个录口了。
------解决方案--------------------
同意一楼的!!!
------解决方案--------------------
<bean id="jsglListAction" class="com.asideal.struts.jsgl.action.JsglListAction">
<property name="jsglService">
<ref bean="jsglService" />
</property>
</bean>

<bean id="jsglService" parent="baseTransactionProxyBean" >
<property name="target" >
<bean class="com.asideal.struts.jsgl.service.JsglService" autowire="byName">
<property name="jsglDao">
<ref bean="jsDao"/>
</property>
</bean>
</property>
</bean>

<bean id="jsDao" class="com.asideal.struts.jsgl.dao.JsglDao">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>