1124刘润杭hibernate与spring整合Word格式文档下载.docx

上传人:b****2 文档编号:5828635 上传时间:2023-05-05 格式:DOCX 页数:7 大小:43.62KB
下载 相关 举报
1124刘润杭hibernate与spring整合Word格式文档下载.docx_第1页
第1页 / 共7页
1124刘润杭hibernate与spring整合Word格式文档下载.docx_第2页
第2页 / 共7页
1124刘润杭hibernate与spring整合Word格式文档下载.docx_第3页
第3页 / 共7页
1124刘润杭hibernate与spring整合Word格式文档下载.docx_第4页
第4页 / 共7页
1124刘润杭hibernate与spring整合Word格式文档下载.docx_第5页
第5页 / 共7页
1124刘润杭hibernate与spring整合Word格式文档下载.docx_第6页
第6页 / 共7页
1124刘润杭hibernate与spring整合Word格式文档下载.docx_第7页
第7页 / 共7页
亲,该文档总共7页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

1124刘润杭hibernate与spring整合Word格式文档下载.docx

《1124刘润杭hibernate与spring整合Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《1124刘润杭hibernate与spring整合Word格式文档下载.docx(7页珍藏版)》请在冰点文库上搜索。

1124刘润杭hibernate与spring整合Word格式文档下载.docx

xsi:

schemaLocation="

//www.springframework.org/schema/beans

http:

//www.springframework.org/schema/beans/spring-beans.xsd

//www.springframework.org/schema/tx

//www.springframework.org/schema/tx/spring-tx-3.2.xsd

//www.springframework.org/schema/aop

//www.springframework.org/schema/aop/spring-aop-3.2.xsd"

<

!

--引入属性文件-->

bean

class="

org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"

<

propertyname="

locations"

value="

classpath:

jdbc.properties"

/>

/bean>

--配置数据源-->

beanname="

dataSource"

class="

mons.dbcp.BasicDataSource"

destroy-method="

close"

driverClassName"

${jdbc.driver}"

url"

${jdbc.url}"

username"

${jdbc.username}"

password"

${jdbc.password}"

--初始化连接大小-->

initialSize"

0"

--连接池最大使用连接数量-->

maxActive"

20"

--连接池最大空闲-->

maxIdle"

--连接池最小空闲-->

minIdle"

--获取连接最大等待时间-->

maxWait"

60000"

validationQuery"

${validationQuery}"

testOnBorrow"

false"

testOnReturn"

testWhileIdle"

true"

--配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒-->

timeBetweenEvictionRunsMillis"

--配置一个连接在池中最小生存的时间,单位是毫秒-->

minEvictableIdleTimeMillis"

25200000"

--打开removeAbandoned功能-->

removeAbandoned"

--1800秒,也就是30分钟-->

removeAbandonedTimeout"

1800"

--关闭abanded连接时输出错误日志-->

logAbandoned"

--配置hibernatesession工厂-->

beanid="

sessionFactory"

org.springframework.orm.hibernate4.LocalSessionFactoryBean"

ref="

/property>

hibernateProperties"

<

props>

<

propkey="

hibernate.dialect"

${hibernate.dialect}<

/prop>

hibernate.hbm2ddl.auto"

${hibernate.hbm2ddl.auto}<

hibernate.show_sql"

${hibernate.show_sql}<

hibernate.format_sql"

${hibernate.format_sql}<

/props>

--扫描hibernate注解配置的entity

packagesToScan"

com.whxh.news.model"

-->

--下面是配置文件的方式-->

mappingLocations"

value>

/com/whxh/news/model/*.hbm.xml<

/value>

--配置事务管理器-->

transactionManager"

org.springframework.orm.hibernate4.HibernateTransactionManager"

--注解方式配置事物-->

tx:

annotation-driventransaction-manager="

--拦截器方式配置事务-->

adviceid="

transactionAdvice"

transaction-manager="

attributes>

methodname="

add*"

propagation="

REQUIRED"

save*"

update*"

modify*"

edit*"

delete*"

remove*"

get*"

SUPPORTS"

read-only="

find*"

*"

/tx:

advice>

--配置aop-->

aop:

config>

pointcutexpression="

execution(*com.whxh.service.*.*(..))"

id="

transactionPointcut"

advisoradvice-ref="

pointcut-ref="

/aop:

/beans>

Web.xml中

servlet>

servlet-name>

spring<

/servlet-name>

servlet-class>

org.springframework.web.servlet.DispatcherServlet<

/servlet-class>

init-param>

param-name>

contextConfigLocation<

/param-name>

param-value>

classpath*:

applicationContext.xml,

classpath*:

applicationContext-mvc.xml,

spring-hibernate.xml<

/param-value>

/init-param>

load-on-startup>

1<

/load-on-startup>

/servlet>

servlet-mapping>

url-pattern>

/<

/url-pattern>

/servlet-mapping>

建立实体类的xml

DOCTYPEhibernate-mappingPUBLIC

"

-//Hibernate/HibernateMappingDTD3.0//EN"

//www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"

hibernate-mappingpackage="

classname="

AdminEntity"

table="

t_admin"

>

--id此id不是数据库种的字段,而是对当前数据的唯一标识-->

idname="

id"

column="

--指明自增的方式-->

generatorclass="

native"

/generator>

/id>

upass"

name"

status"

/class>

/hibernate-mapping>

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 外语学习 > 日语学习

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2