lt;/bean> <!-- 配置数据持久层 --> <bean id="userDao" class="com.ssh.dao.impl.UserDaoImpl"> <property name="hibernateTemplate" ref="hibernateTemplate"></property> </bean> <!-- 配置业务逻辑层 --> <bean id="userService" class="com.ssh.service.impl.UserServiceImpl"> <property name="userDao" ref="userDao"></property> </bean> <!-- 配置控制层 --> <bean id="UserAction" class="com.ssh.action.UserAction" scope="prototype"> <property name="userService" ref="userService"></property> </bean> <!-- 配置pojo --> <bean id="User" class="com.ssh.pojo.User" scope="prototype"/></beans> 下面是详解: 1.基本配置:<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd "> <context:component-scan base-package="com.persia"><!-- 开启组件扫描 --></context:component-scan> <context:annotation-config><!--开启注解处理器--></context:annotation-config> <!-- 使用注解,省去了propertity的xml配置,减少xml文件大小 --><bean id="personServiceAnno" class="com.persia.PersonServiceAnnotation"></bean><bean id="personDaoBeanAnno" class="com.persia.PersonDaoBean"></bean><bean id="personDaoBeanAnno2" class="com.persia.PersonDaoBean"></bean> <!-- 自动注解 --><bean id="personServiceAutoInject" class="com.persia.PersonServiceAutoInject" autowire="byName"></bean> <bean id="personService" class="com.persia.PersonServiceBean"><!-- 由spring容器去创建和维护,我们只要获取就可以了 --></bean> <bean id="personService2" class="com.persia.PersonServiceBeanFactory" factory-method="createInstance" lazy-init="true" &nbs