参考了很多网友的文章和文档.现将Spring+Hibernate+Proxool的配置发表如下:
首先是一个普通的Proxool配置文件
proxool.xml

















这里面的内容没什么好讲的了,如果不懂的话参考本blog的其它相关文章
Spring的配置文件
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
<beans>
4
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" singleton="true">
5
<property name="hibernateProperties">
6
<props>
7
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
8
<prop key="hibernate.show_sql">true</prop>
9
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
10
<prop key="hibernate.proxool.xml">proxool.xml</prop>
11
<prop key="hibernate.proxool.pool_alias">DBPool</prop>
12
</props>
13
</property>
14
<property name="mappingResources">
15
<list>
16
<value>User.hbm.xml</value>
17
</list>
18
</property>
19
</bean>
20
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
21
<property name="sessionFactory">
22
<ref local="mySessionFactory"/>
23
</property>
24
</bean>
25
<bean id="userDao" class="com.ycoe.blog2.impl.UserDaoImpl">
26
<property name="sessionFactory">
27
<ref local="mySessionFactory"/>
28
</property>
29
</bean>
30
</beans>
31

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

29

30

31

这里有几个要注意的地方:
1.这两个文档的放置目录的问题.说得简单些就是要放在classpath路径中.
2.hibernate.proxool.pool_alias要和proxool.xml中配置的一样!
3.mappingResources可以将它从这个配置文件中独立来开,以提高配置的结构,易于修改,同理也适用于其它的事务配置
有些配置细节不再在些处细说,详见本blog的其它文章!
相关文件下载:https://files.cnblogs.com/ycoe/Spring+Proxool+Hibernate.rar(里面附详细使用说明)
可以说已经配置完成了,就是这么简单!可以看到Spring的优美,简单,真让人拍案叫绝
--原创文章,可以随意复制,发表,但请注明出处和作者信息,谢谢合作!
By YCOE
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)