问答详情
源自:4-3 修改员工

关于spplicationContext.xml里面类的配置简化问题

因为每一个实体类都要在spplicationContext.xml中配置Action的类,配置Service,配置DAO类。有没有注解的方式或者其他方式,有代码的可以贴一下

提问者:xiemaoyu 2018-08-30 19:07

个回答

  • xiemaoyu
    2018-08-30 20:33:09

    有使用注解的不?

    <!-- 配置Action由spring自动创建 -->

    <bean id="employeeAction" class="com.muke.employee.action.EmployeeAction" scope="prototype">

    <property name="employeeService" ref="employeeService"/>

    <property name="departmentService" ref="departmentService"/>

    </bean>

    <bean id="departmentAction" class="com.muke.employee.action.DepartmentAction" scope="prototype">

    <property name="departmentService" ref="departmentService"/>

    </bean>

    <!-- 配置业务层的类 -->

    <bean id="employeeService" class="com.muke.employee.service.impl.EmployeeServiceImpl">

    <property name="employeeDao" ref="employeeDao"/>

    </bean>

    <bean id="departmentService" class="com.muke.employee.service.impl.DepartmentServiceImpl">

    <property name="departmentDao" ref="departmentDao"/>

    </bean>

    <!-- 配置DAO的类 -->

    <bean id="employeeDao" class="com.muke.employee.dao.impl.EmployeeDaoImpl">

    <property name="sessionFactory" ref="sessionFactory"/>

    </bean>

    <bean id="departmentDao" class="com.muke.employee.dao.impl.DepartmentDaoImpl">

    <property name="sessionFactory" ref="sessionFactory"/>

    </bean>