關(guān)于spplicationContext.xml里面類的配置簡(jiǎn)化問題
因?yàn)槊恳粋€(gè)實(shí)體類都要在spplicationContext.xml中配置Action的類,配置Service,配置DAO類。有沒有注解的方式或者其他方式,有代碼的可以貼一下
因?yàn)槊恳粋€(gè)實(shí)體類都要在spplicationContext.xml中配置Action的類,配置Service,配置DAO類。有沒有注解的方式或者其他方式,有代碼的可以貼一下
舉報(bào)
2018-08-30
有使用注解的不?
<!-- 配置Action由spring自動(dòng)創(chuàng)建 -->
<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>
<!-- 配置業(yè)務(wù)層的類 -->
<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>