Spring下载地址: http://repo.springsource.org/libs-release-local/org/springframework/spring/
Hhibernate下载地址: http://sourceforge.net/projects/hibernate/files/
1. jar包引入
spring-framework-4.0.0.RELEASE(18个):libs文件夹中除却spring-build-src-4.0.0.RELEASE.jar、spring-framework-bom-4.0.0.RELEASE.jar、spring-messaging-4.0.0.RELEASE.jar、spring-websocket-4.0.0.RELEASE.jar四个jar包,其它全部导入,共18个jar包。
spring依赖包:aopalliance.jar、commons-logging-1.1.1.jar、log4j-1.2.15.jar
hibernate-release-4.3.0.Final(10个):lib文件夹中required文件夹下的10个jar包。
hibernate 缓存包(4个):ehcache-core-2.4.3.jar、hibernate-ehcache-4.3.0.Final.jar、slf4j-api-1.7.5.jar、slf4j-log4j12-1.7.5.jar
其他工具包(9个):commons-fileupload-1.3.jar、commons-io-2.4.jar、commons-lang3-3.2.jar、commons-beanutils-1.9.0.jar、commons-dbcp-1.4.jar、commons-pool-1.6.jar、pager-taglib.jar、commons-collections-3.2.1.jar、mysql-connector-java-5.1.27.jar
- 配置文件
(1) web.xml配置
关于filter的使用,可以参考:Spring MVC过滤器-登录过滤
- <?xmlversionxmlversion="1.0" encoding="UTF-8"?>
- <web-appversionweb-appversion="3.0"
- xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
- <display-name>SpringMVC</display-name>
- <welcome-file-list>
- <welcome-file>index.html</welcome-file>
- <welcome-file>index.htm</welcome-file>
- <welcome-file>index.jsp</welcome-file>
- <welcome-file>default.html</welcome-file>
- <welcome-file>default.htm</welcome-file>
- <welcome-file>default.jsp</welcome-file>
- </welcome-file-list>
- <!--加载spring的配置文件 -->
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath*:config/applicationContext-*.xml</param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <!--springMVC 框架加载服务 -->
- <servlet>
- <servlet-name>springMVC</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <init-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath*:config/applicationContext-springmvc.xml</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>springMVC</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
- <!--filter配置,解决编码问题 -->
- <filter>
- <filter-name>encodingFilter</filter-name>
- <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
- <init-param>
- <param-name>encoding</param-name>
- <param-value>UTF-8</param-value>
- </init-param>
- <init-param>
- <param-name>forceEncoding</param-name>
- <param-value>true</param-value>
- </init-param>
- </filter>
- <!--encoding filter for jsp page -->
- <filter-mapping>
- <filter-name>encodingFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <!--sessionFilter配置,解决session过滤问题 -->
- <filter>
- <filter-name>sessionFilter</filter-name>
- <filter-class>com.springmvc.core.web.filter.SessionFilter</filter-class>
- <init-param>
- <param-name>notFilter</param-name>
- <param-value>/skin/,/index.jsp, /mvc/index, /login, /logout</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>sessionFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <!--OpenSessionInViewFilter配置,解决延迟加载时Session会关闭的问题 -->
- <filter>
- <filter-name>openSession</filter-name>
- <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>openSession</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <!--配置PagerFilter,用来获取分页数据 -->
- <filter>
- <filter-name>pagerFilter</filter-name>
- <filter-class>com.springmvc.core.web.filter.PagerFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>pagerFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <!--session time out 23*60 -->
- <session-config>
- <session-timeout>1380</session-timeout>
- </session-config>
- </web-app>
(2)applicationContext-springmvc.xml配置
此为spring核心配置文件
关于spring使用annotation注解,可以参考:1. 基于注解的 Spring MVC 简单入门 2. 基于注解的SpringMVC
- <?xmlversionxmlversion="1.0" encoding="UTF-8"?>
- <!--
- -DispatcherServlet application context for DeclareOnline's web tier.
- springmvc 的 DispatcherServlet 对应的配置文件
- -->
- <beansxmlnsbeansxmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.0.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
- <!--
- -The controllers are autodetected POJOs labeled with the @Controller annotation.
- Springmvc将在该路径下寻找Controller(有Controller注释的类)
- -->
- <context:component-scanbase-packagecontext:component-scanbase-package="com.springmvc.*"/>
- <!--开启注解 -->
- <mvc:annotation-driven/>
- <!--使用依赖控制器类名字的惯例,将URI映射到控制器(开启注解的另一种方式) -->
- <!--
- <beanclassbeanclass="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
- <beanclassbeanclass="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
- 启动SpringMVC的注解功能,完成请求和注解POJO的映射
- <beanclassbeanclass="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
- -->
- <!--静态资源访问 -->
- <mvc:resourceslocationmvc:resourceslocation="/skin/" mapping="/skin/**"/>
- <!--定义Spring MVC 的模板文件 -->
- <beanidbeanid="viewResolver"class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <!--支持JSTL -->
- <propertynamepropertyname="viewClass"value="org.springframework.web.servlet.view.JstlView"/>
- <!--模板的路径 -->
- <propertynamepropertyname="prefix" value="/" />
- <!--模板文件后缀 -->
- <propertynamepropertyname="suffix" value=".jsp" />
- </bean>
- <!-- Spring MVC 文件上传配置 -->
- <beanidbeanid="multipartResolver"
- class="org.springframework.web.multipart.commons.CommonsMultipartResolver"
- p:defaultEncoding="utf-8">
- <propertynamepropertyname="maxUploadSize">
- <value>10485760000</value>
- </property>
- <propertynamepropertyname="maxInMemorySize">
- <value>40960</value>
- </property>
- </bean>
- </beans>
(3)applicationContext-hibernate.xml配置
A. 此文件是spring方式的hibernate连接数据库的配置
spring配置数据库连接方式有很多种,可以参考一下: 在Spring中配置DataSource的6种方法
此处使用了Spring利用PropertyPlaceholderConfigurer占位符,参考文章: Spring 利用PropertyPlaceholderConfigurer占位符
Spring事务配置的方式也有多中,可以参考: Spring事务配置的五种方式和spring里面事务的传播属性和事务隔离级别
applicationContext-hibernate.xml
- <?xmlversionxmlversion="1.0" encoding="UTF-8"?>
- <beansxmlnsbeansxmlns="http://www.springframework.org/schema/beans"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsd
- http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd
- http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsd
- http://www.springframework.org/schema/utilhttp://www.springframework.org/schema/util/spring-util-2.0.xsd"default-lazy-init="false">
- <!--======================== property configure本配置文件负责加载变量信息必须在在spring配置文件的最前面加载(第一个加载) ======================== -->
- <!--载入properties配置文件,以${key}的方式引用 -->
- <beanidbeanid="propertyConfigurer"
- class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <propertynamepropertyname="locations">
- <list>
- <value>classpath:conf/mvcdb.properties</value>
- </list>
- </property>
- </bean>
- <!--======================== dataconfigure ==========================-->
- <!--配置连接池(jdbc方式) -->
- <!--<bean id="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <propertynamepropertyname="driverClassName" value="${mvcdb.mysql.driver}"/>
- <propertynamepropertyname="url" value="${mvcdb.mysql.url}"/>
- <propertynamepropertyname="username" value="${mvcdb.mysql.user}"/>
- <propertynamepropertyname="password" value="${mvcdb.mysql.password}"/>
- </bean>-->
- <beanidbeanid="dataSource"
- class="org.apache.commons.dbcp.BasicDataSource"
- destroy-method="close">
- <propertynamepropertyname="driverClassName">
- <value>${mvcdb.mysql.driver}</value>
- </property>
- <propertynamepropertyname="url">
- <value>${mvcdb.mysql.url}</value>
- </property>
- <propertynamepropertyname="username">
- <value>${mvcdb.mysql.user}</value>
- </property>
- <propertynamepropertyname="password">
- <value>${mvcdb.mysql.password}</value>
- </property>
- <propertynamepropertyname="initialSize">
- <value>${mvcdb.mysql.initialSize}</value>
- </property>
- <propertynamepropertyname="maxActive">
- <value>${mvcdb.mysql.maxActive}</value>
- </property>
- <property name="minIdle">
- <value>${mvcdb.mysql.maxActive}</value>
- </property>
- <propertynamepropertyname="maxIdle">
- <value>${mvcdb.mysql.maxActive}</value>
- </property>
- <propertynamepropertyname="maxWait">
- <value>${mvcdb.mysql.maxWait}</value>
- </property>
- <propertynamepropertyname="testOnBorrow">
- <value>${mvcdb.mysql.testOnBorrow}</value>
- </property>
- <propertynamepropertyname="testWhileIdle">
- <value>${mvcdb.mysql.testWhileIdle}</value>
- </property>
- <propertynamepropertyname="validationQuery">
- <value>${mvcdb.mysql.validationQuery}</value>
- </property>
- </bean>
- <!--配置hibernate 上下文 -->
- <beanidbeanid="sessionFactory"class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
- <propertynamepropertyname="dataSource" ref="dataSource" />
- <!--包级扫描 hibernate实体类 -->
- <propertynamepropertyname="configLocations">
- <list>
- <!--<value>com.springmvc.*</value> -->
- <value>classpath*:com/springmvc/mvcdev/userInfo/hibernate/hibernate.cfg.userInfo.xml</value>
- </list>
- </property>
- <propertynamepropertyname="hibernateProperties">
- <props>
- <propkeypropkey="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</prop>
- <propkeypropkey="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
- <propkeypropkey="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
- <propkeypropkey="hibernate.cache.use_query_cache">false</prop>
- <propkeypropkey="hibernate.show_sql">true</prop>
- <!--<prop key="hibernate.hbm2ddl.auto">update</prop> -->
- <propkeypropkey="hibernate.cache.use_second_level_cache">false</prop>
- <propkeypropkey="hibernate.max_fetch_depth">2</prop>
- <propkeypropkey="hibernate.jdbc.fetch_size">50</prop>
- <propkeypropkey="hibernate.jdbc.batch_size">50</prop>
- <propkeypropkey="hibernate.use_outer_join">false</prop>
- <propkeypropkey="hibernate.format_sql">true</prop>
- </props>
- </property>
- </bean>
- <!-- 配置jdbc事务 -->
- <beanidbeanid="transactionManager"class="org.springframework.orm.hibernate4.HibernateTransactionManager">
- <propertynamepropertyname="sessionFactory">
- <reflocalreflocal="sessionFactory" />
- </property>
- </bean>
- <!--配置启用事务的动态代理 -->
- <beanidbeanid="baseTransactionProxy"class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"abstract="true">
- <propertynamepropertyname="transactionManager">
- <refbeanrefbean="transactionManager" />
- </property>
- <propertynamepropertyname="proxyTargetClass" value="true"/>
- <propertynamepropertyname="transactionAttributes">
- <props>
- <propkeypropkey="insert*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="active*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="end*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="lock*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="unLock*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="update*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="modify*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="delete*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="remove*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="del*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="add*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="save*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="set*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="exchage*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="sort*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="do*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="undo*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="transact*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="enrolment*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="accept*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="init*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="edit*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="create*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="support*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="active*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="mapping*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="reset*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="change*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="submit*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="draft*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="assign*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="close*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="suspend*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="publish*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="revoke*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="print*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="undeploy*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="suspend*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="resume*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="rand*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="send*">PROPAGATION_REQUIRED,-Exception</prop>
- <propkeypropkey="*">PROPAGATION_REQUIRED,readOnly</prop>
- </props>
- </property>
- </bean>
- </beans>
B.此文件需要在mvcdb.properties文件中配置数据库的相关信息。
mvcdb.properties
- #=================================================
- #mysql connection parameters
- #=================================================
- mvcdb.mysql.driver=com.mysql.jdbc.Driver
- mvcdb.mysql.url=jdbc:mysql://localhost:3306/zszx?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
- mvcdb.mysql.user=root
- mvcdb.mysql.password=123456
- mvcdb.mysql.initialSize=2
- mvcdb.mysql.maxActive=10000
- mvcdb.mysql.minIdle=5
- mvcdb.mysql.maxIdle=2
- mvcdb.mysql.maxWait=600000
- mvcdb.mysql.testOnReturn=false
- mvcdb.mysql.testWhileIdle=true
- mvcdb.mysql.testOnBorrow=true
- mvcdb.mysql.validationQuery=select1
C.此文件扫描hibernate实体时扫描的文件,此处以hibernate.cfg.userInfo.xml为例。
hibernate.cfg.userInfo.xml
- <!DOCTYPEhibernate-configuration PUBLIC
- "-//Hibernate/HibernateConfiguration DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
- <hibernate-configuration>
- <session-factory>
- <!--用户映射实体 -->
- <mappingclassmappingclass="com.springmvc.mvcdev.userInfo.domain.Userinfo"/>
- </session-factory>
- </hibernate-configuration>
D.Userinfo实体类使用注解方式关联数据库。
Hibernate 使用注解,可以参考:1. Hibernate Annotation 2.Hibernate4实战之Hibernate4注解零配置
Userinfo.java
- packagecom.springmvc.mvcdev.userInfo.domain;
- importjava.io.Serializable;
- importjavax.persistence.Column;
- importjavax.persistence.Entity;
- importjavax.persistence.Id;
- importjavax.persistence.Table;
- /**
- * 用户实体类
- *
- * @ClassName: Userinfo
- * @author: QuBinBin
- * @date: 2014-1-3 上午10:53:36
- *
- */
- @Entity
- @Table(name= "userinfo")
- publicclass Userinfo implements Serializable {
- privatestatic final long serialVersionUID = -8047186992943452353L;
- /**
- * 主键ID
- */
- @Id
- @Column(name= "ID", unique = true, nullable = false)
- privateInteger id;
- /**
- * 用户账号
- */
- @Column(name= "NAME", length = 200)
- privateString name;
- /**
- * 用户真实姓名
- */
- @Column(name= "TRUENAME", length = 200)
- privateString truename;
- /**
- * 用户密码
- */
- @Column(name= "PWD", length = 100)
- privateString pwd;
- /**
- */
- @Column(name= "EMAIL", length = 50)
- privateString email;
- /**
- * 手机
- */
- @Column(name= "MOBILE", length = 20)
- privateString mobile;
- /**
- * 状态(1激活 0禁用)
- */
- @Column(name= "STATUS")
- privateInteger status;
- publicInteger getId() {
- returnthis.id;
- }
- publicvoid setUserId(Integer id) {
- this.id= id;
- }
- publicString getName() {
- returnthis.name;
- }
- publicvoid setName(String name) {
- this.name= name;
- }
- publicString getTruename() {
- returnthis.truename;
- }
- publicvoid setTruename(String truename) {
- this.truename= truename;
- }
- publicString getPwd() {
- returnthis.pwd;
- }
- publicvoid setPwd(String pwd) {
- this.pwd= pwd;
- }
- publicString getEmail() {
- returnemail;
- }
- publicvoid setEmail(String email) {
- this.email= email;
- }
- publicString getMobile() {
- returnmobile;
- }
- publicvoid setMobile(String mobile) {
- this.mobile= mobile;
- }
- publicInteger getStatus() {
- returnthis.status;
- }
- publicvoid setStatus(Integer status) {
- this.status= status;
- }
- }
(4)applicationContext-import.xml配置
此文件配置依赖注入的内容
applicationContext-import.xml
- <?xmlversionxmlversion="1.0" encoding="UTF-8"?>
- <!--
- - Application context definition forJPetStore's business layer.
- - Contains bean references to the transactionmanager and to the DAOs in
- - dataAccessContext-local/jta.xml (seeweb.xml's "contextConfigLocation").
- -->
- <beansxmlnsbeansxmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.0.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"
- >
- <importresourceimportresource="classpath*:com/springmvc/mvcdev/userInfo/spring/applicationContext-userInfo.xml"/>
- </beans>
具体注入内容在import的每个模块下的xml文件中。此处以applicationContext-userInfo.xml为例。
applicationContext-userInfo.xml
- <?xmlversionxmlversion="1.0" encoding="UTF-8"?>
- <beansxmlnsbeansxmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://www.springframework.org/schema/utilhttp://www.springframework.org/schema/util/spring-util-2.0.xsd">
- <!--******************************用户********************* -->
- <!--Hibernate 用户持久化访问接口 -->
- <beanidbeanid="userInfoDAO"class="com.springmvc.mvcdev.userInfo.dao.impl.UserInfoDAOImpl">
- <propertynamepropertyname="sessionFactory" ref="sessionFactory"/>
- </bean>
- <beanidbeanid="userInfoServiceImpl"class="com.springmvc.mvcdev.userInfo.service.impl.UserInfoServiceImpl">
- <propertynamepropertyname="userInfoDAO" ref="userInfoDAO"></property>
- </bean>
- <!--事务控制 -->
- <beanidbeanid="userInfoService" parent="baseTransactionProxy">
- <propertynamepropertyname="target" ref="userInfoServiceImpl"/>
- </bean>
- </beans>
- 参考资料
Spring MVC 教程,快速入门,深入分析: http://elf8848.iteye.com/blog/875830/