Alpha
多少春秋風(fēng)雨改 多少崎嶇不變愛
BlogJava
首頁
新隨筆
聯(lián)系
聚合
管理
隨筆-179 評(píng)論-666 文章-29 trackbacks-0
Spring+Hibernate的配制
1.applicationContext.xml 文件的配制:
1
<?
xml version="1.0" encoding="UTF-8"
?>
2
<!
DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"
>
3
4
<
beans
>
5
6
<
bean
id
="dataSource"
class
="org.apache.commons.dbcp.BasicDataSource"
destroy-method
="close"
>
7
8
<
property
name
="driverClassName"
>
9
<
value
>
com.mysql.jdbc.Driver
</
value
>
10
</
property
>
11
12
<
property
name
="url"
>
13
<
value
>
jdbc:mysql://192.168.2.186/task
</
value
>
14
</
property
>
15
16
<
property
name
="username"
>
17
<
value
>
task
</
value
>
18
</
property
>
19
20
<
property
name
="password"
>
21
<
value
>
123
</
value
>
22
</
property
>
23
</
bean
>
24
25
<
bean
id
="sessionFactory"
class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
singleton
="true"
>
26
27
<
property
name
="dataSource"
>
28
<
ref
local
="dataSource"
/>
29
</
property
>
30
31
<
property
name
="mappingResources"
>
32
<
list
>
33
<
value
>
com/task/hibernatemap/xml/UserInfo.hbm.xml
</
value
>
34
<
value
>
com/task/hibernatemap/xml/Apply.hbm.xml
</
value
>
35
<
value
>
com/task/hibernatemap/xml/Approve.hbm.xml
</
value
>
36
<
value
>
com/task/hibernatemap/xml/Discription.hbm.xml
</
value
>
37
<
value
>
com/task/hibernatemap/xml/Person.hbm.xml
</
value
>
38
<
value
>
com/task/hibernatemap/xml/ItemName.hbm.xml
</
value
>
39
<
value
>
com/task/hibernatemap/xml/ItemVersion.hbm.xml
</
value
>
40
</
list
>
41
</
property
>
42
43
<
property
name
="hibernateProperties"
>
44
<
props
>
45
<
prop
key
="hibernate.dialect"
>
org.hibernate.dialect.MySQLDialect
</
prop
>
46
<
prop
key
="hibernate.show_sql"
>
false
</
prop
>
47
</
props
>
48
</
property
>
49
</
bean
>
50
51
<
bean
id
="transactionManager"
class
="org.springframework.orm.hibernate3.HibernateTransactionManager"
>
52
<
property
name
="sessionFactory"
>
53
<
ref
local
="sessionFactory"
/>
54
</
property
>
55
</
bean
>
56
57
<
bean
id
="hibernateDao"
class
="com.task.common.HibernateDao"
>
58
<
property
name
="sessionFactory"
>
59
<
ref
local
="sessionFactory"
/>
60
</
property
>
61
<
property
name
="transactionManager"
>
62
<
ref
local
="transactionManager"
/>
63
</
property
>
64
</
bean
>
65
66
<
bean
id
="hibernateDaoProxy"
singleton
="true"
class
="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
>
67
<
property
name
="transactionManager"
>
68
<
ref
bean
="transactionManager"
/>
69
</
property
>
70
71
<
property
name
="target"
>
72
<
ref
local
="hibernateDao"
/>
73
</
property
>
74
75
<
property
name
="transactionAttributes"
>
76
<
props
>
77
<
prop
key
="save*"
>
PROPAGATION_REQUIRED
</
prop
>
78
<
prop
key
="remove*"
>
PROPAGATION_REQUIRED
</
prop
>
79
<
prop
key
="update*"
>
PROPAGATION_REQUIRED
</
prop
>
80
<
prop
key
="*"
>
PROPAGATION_REQUIRED,readOnly
</
prop
>
81
</
props
>
82
</
property
>
83
</
bean
>
84
85
</
beans
>
86
2.web.xml 文件的配制:
1
<?
xml version="1.0" encoding="ISO-8859-1"
?>
2
3
<!
DOCTYPE web-app
4
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
5
"http://java.sun.com/dtd/web-app_2_3.dtd"
>
6
7
<
web-app
>
8
9
<
filter
>
10
<
filter-name
>
openSessionInViewFilter
</
filter-name
>
11
<
filter-class
>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</
filter-class
>
12
</
filter
>
13
<
filter-mapping
>
14
<
filter-name
>
openSessionInViewFilter
</
filter-name
>
15
<
url-pattern
>
/*
</
url-pattern
>
16
</
filter-mapping
>
17
18
<
listener
>
19
<
listener-class
>
org.springframework.web.context.ContextLoaderListener
</
listener-class
>
20
</
listener
>
21
22
23
<
servlet
>
24
<
servlet-name
>
task
</
servlet-name
>
25
<
servlet-class
>
org.springframework.web.servlet.DispatcherServlet
</
servlet-class
>
26
<
load-on-startup
>
1
</
load-on-startup
>
27
</
servlet
>
28
29
<
servlet-mapping
>
30
<
servlet-name
>
task
</
servlet-name
>
31
<
url-pattern
>
*.job
</
url-pattern
>
32
</
servlet-mapping
>
33
34
<
welcome-file-list
>
35
<
welcome-file
>
index.jsp
</
welcome-file
>
36
</
welcome-file-list
>
37
</
web-app
>
3.
task
-servlet.xml 文件的配制:
1
<?
xml version="1.0" encoding="UTF-8"
?>
2
<!
DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"
>
3
4
<
beans
>
5
6
<
bean
id
="listController"
class
="com.task.controller.ListController"
>
7
<
property
name
="defaultPage"
><
value
>
/list
</
value
></
property
>
8
</
bean
>
9
10
11
<
bean
id
="urlMapping"
class
="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"
>
12
<
property
name
="mappings"
>
13
<
props
>
14
<
prop
key
="/list*"
>
listController
</
prop
>
15
</
props
>
16
</
property
>
17
</
bean
>
18
19
<
bean
id
="viewResolver"
class
="org.springframework.web.servlet.view.InternalResourceViewResolver"
>
20
<
property
name
="viewClass"
>
21
<
value
>
org.springframework.web.servlet.view.JstlView
</
value
>
22
</
property
>
23
<
property
name
="suffix"
><
value
>
.jsp
</
value
></
property
>
24
</
bean
>
25
26
</
beans
>
27
需要注意的是,第三個(gè)文件的文件名一定要與第二個(gè)文件中黃色字體名字一樣!
posted on 2006-02-10 09:54
Alpha
閱讀(1329)
評(píng)論(3)
編輯
收藏
所屬分類:
Spring
評(píng)論:
#
re: Spring+Hibernate的配制 2006-02-13 12:34 |
Jet Geng
好東西。mappingResources這個(gè)屬性我找了很久了。呵呵。
謝謝了
回復(fù)
更多評(píng)論
#
re: Spring+Hibernate的配制 2006-03-16 11:39 |
liuzhiwen
明顯就是橙色,華哥,你不行啊
回復(fù)
更多評(píng)論
#
re: Spring+Hibernate的配制[未登錄]
2010-05-22 09:20 |
aa
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
回復(fù)
更多評(píng)論
新用戶注冊(cè)
刷新評(píng)論列表
只有注冊(cè)用戶
登錄
后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
使用Spring MVC表單標(biāo)簽
【轉(zhuǎn)載】Spring入門
Spring+Hibernate的配制
今日記一事,明日悟一理,積久而成學(xué)。
<
2006年2月
>
日
一
二
三
四
五
六
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
10
11
常用鏈接
我的隨筆
我的評(píng)論
我的參與
最新評(píng)論
留言簿
(32)
給我留言
查看公開留言
查看私人留言
隨筆分類
(182)
Android 移動(dòng)開發(fā)
Hibernate(2)
Java J2EE JSP(31)
jQuery JavaScript Flex(5)
Linux Nginx(28)
MySQL NoSQL(14)
PHP ThinkPHP(2)
SEO優(yōu)化 網(wǎng)站推廣(1)
Spring(3)
吳語輪筆(81)
吾亦好攝(8)
開源開發(fā)工具使用(2)
網(wǎng)站設(shè)計(jì) 用戶體驗(yàn)(5)
文章分類
(39)
J2EE+JSP(1)
JavaScript(9)
Linux、操作系統(tǒng)(9)
人生哲理(4)
多愁善感(11)
憤青集中營(2)
數(shù)據(jù)庫SQL(3)
相冊(cè)
06圣誕節(jié)
07.1.7水濂山
07年元旦
原創(chuàng)圖片
雜七雜八
校慶
梅花
友情鏈接
VIP卡云
壞男孩
田逸blog
黎波
我的地盤
技術(shù)文檔
CSS 樣式表參考文檔
DHTML 參考手冊(cè)
DWR中文文檔
MySQL 5.1參考手冊(cè)
Spring Framework 開發(fā)參考手冊(cè)
灰狐文檔中心
搜索
積分與排名
積分 - 1330303
排名 - 20
最新隨筆
1.?Centos7安裝Nginx+PHP+MySQL
2.?Ubuntu完美安裝搭建Git服務(wù)器
3.?Git本地服務(wù)器搭建及使用詳解
4.?Linux 常見運(yùn)維命令
5.?Linux怎樣恢復(fù)誤刪除的數(shù)據(jù)
6.? CentOS 7 安裝 Nginx、PHP7、PHP-FPM
7.?Tomcat8 安全配置與性能優(yōu)化
8.?Ubuntu14.04下部署FastDFS 5.08+Nginx 1.9.14
9.?Ubuntu14.04下搭建VPN服務(wù)
10.?CentOS 6.4 配置VPN服務(wù)教程
最新評(píng)論
1.?re: Ubuntu14.04下部署FastDFS 5.08+Nginx 1.9.14
相當(dāng)成功
--reatang
2.?re: mysql alter 語句用法,添加、修改、刪除字段等
密密麻麻嗎
--,,,
3.?eettafellamp
評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--eettafellamp
4.?re: 使用Spring MVC表單標(biāo)簽
水電費(fèi)
-- 低調(diào)
5.?aanrechtblad
評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--aanrechtblad
6.?re: Tomcat8 安全配置與性能優(yōu)化[未登錄]
評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--aa
7.?re: Tomcat8 安全配置與性能優(yōu)化[未登錄]
評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--aa
8.?aa[未登錄]
啊啊啊啊
--aa
9.?re: Ubuntu14.04下部署FastDFS 5.08+Nginx 1.9.14
可以可以可以
--司馬青衫
10.?re: mysql alter 語句用法,添加、修改、刪除字段等[未登錄]
1111
--a
閱讀排行榜
1.?MySQL的mysqldump工具的基本用法(237571)
2.?mysql alter 語句用法,添加、修改、刪除字段等(166860)
3.?HttpClient 學(xué)習(xí)整理(143518)
4.?c3p0詳細(xì)配置(91825)
5.?Mysql日期和時(shí)間函數(shù)大全(61381)
6.?Hibernate 不同數(shù)據(jù)庫的連接及SQL方言(50282)
7.?iptables 開啟80端口 (32161)
8.?AS與JS相互通信(Flex中調(diào)用js函數(shù))(26668)
9.?使用Spring MVC表單標(biāo)簽(23985)
10.?JFreeChart在JSP中的應(yīng)用實(shí)例(22546)
11.?scrollbar屬性、樣式詳解(20580)
12.?linux+nginx+tomcat負(fù)載均衡,實(shí)現(xiàn)session同步(20435)
13.?多級(jí)反向代理[Squid]下獲取客戶端真實(shí)IP地址(16397)
14.?linux rsync同步設(shè)置詳細(xì)指南(15693)
15.?jsp頁面中,JSTL El表達(dá)式字符串比較常用方法(15590)
評(píng)論排行榜
1.?南雄中學(xué)百年校慶(91)
2.?HttpClient 學(xué)習(xí)整理(44)
3.?JFreeChart在JSP中的應(yīng)用實(shí)例(29)
4.?c3p0詳細(xì)配置(26)
5.?從MySQL得到最大的性能(20)
6.?學(xué)會(huì)如何去愛一個(gè)人(16)
7.?千年珠璣(15)
8.?笑翻天樂園-痛并快樂著(14)
9.?說說我們技術(shù)部(13)
10.?MySQL的mysqldump工具的基本用法(12)
11.?述 職 報(bào) 告(11)
12.?多級(jí)反向代理[Squid]下獲取客戶端真實(shí)IP地址(11)
13.?雙喜臨門(10)
14.?元旦遭遇人山人海(9)
15.?一個(gè)身材超好的MM(7)
Powered by:
博客園
模板提供:
滬江博客
Copyright ©2025 Alpha
主站蜘蛛池模板:
免费国产成人午夜电影
|
国产精品亚洲mnbav网站
|
亚洲AV色无码乱码在线观看
|
国产免费爽爽视频免费可以看
|
一级毛片免费毛片毛片
|
亚洲国产精品自在在线观看
|
国产在线观看片a免费观看
|
亚洲av无码一区二区三区在线播放
|
久久激情亚洲精品无码?V
|
99re6在线视频精品免费下载
|
亚洲午夜福利在线视频
|
狠狠亚洲婷婷综合色香五月排名
|
中国人xxxxx69免费视频
|
青娱乐免费在线视频
|
一级做a爰片久久毛片免费陪
|
少妇性饥渴无码A区免费
|
亚洲成人福利网站
|
亚洲成AV人网址
|
亚洲免费在线视频播放
|
伊人久久国产免费观看视频
|
亚洲午夜电影在线观看高清
|
亚洲国产日韩在线观频
|
国产啪精品视频网免费
|
国产午夜无码片免费
|
亚洲AV永久无码天堂影院
|
亚洲VA中文字幕无码一二三区
|
永久在线毛片免费观看
|
xxxxx免费视频
|
91在线视频免费观看
|
国产精品国产亚洲区艳妇糸列短篇
|
亚洲AV福利天堂一区二区三
|
免费少妇a级毛片
|
扒开双腿猛进入爽爽免费视频
|
99精品在线免费观看
|
久久久久久噜噜精品免费直播
|
亚洲AV无码一区二区三区性色
|
亚洲av中文无码乱人伦在线r▽
|
免费吃奶摸下激烈视频
|
成人av免费电影
|
黄页网站在线看免费
|
www视频在线观看免费
|