欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

在spring中配置proxool、ibatis

程序员文章站 2022-07-14 14:06:00
...
参考了一些资料,整理如下: 1、直接在applicationContext.xml中配置proxool: <!----> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <!----> <!----> <bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" destroy-method="close"> <property name="driver"> <value>com.mysql.jdbc.Driver</value> </property> <property name="driverUrl"> <value>jdbc:mysql://localhost:3306/dev</value> </property> <property name="user"> <!----> <value>root</value> </property> <property name="password"> <!----> <value></value> </property> <property name="alias"> <value>www</value> <!----> </property> <property name="prototypeCount"> <value>5</value> </property> <property name="maximumConnectionCount"> <value>10</value> </property> <property name="minimumConnectionCount"> <value>5</value> </property> <property name="maximumActiveTime"> <value>10000</value> </property> <property name="trace"> <value>true</value> </property> <property name="verbose"> <value>true</value> </property> </bean> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation" value="configure/SqlMapConfig.xml"> <property name="dataSource" ref="dataSource"> </bean> <bean id="aDao" class="aDao"> <property name="sqlMapClient" ref="sqlMapClient"> </bean> </beans> 2、使用外部文件 applicationContext.xml内容: <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>org.logicalcobwebs.proxool.ProxoolDriver</value> </property> <property name="url"> <value>proxool.www</value> </property> </bean> proxool.xml内容: <!----> <proxool> <alias>www</alias> <driver-url>jdbc:mysql://localhost:3306/dev</driver-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <driver-properties> <property name="user" value="root"> <property name="password" value=""> <property name="useUnicode" value="true"> <property name="characterEncoding" value="GBK"> </driver-properties> <maximum-connection-count>10</maximum-connection-count> <minimum-connection-count>5</minimum-connection-count> <maximum-active-time>10000</maximum-active-time> <house-keeping-test-sql>select * from dual</house-keeping-test-sql> </proxool> web.xml内容: <servlet> <servlet-name>proxoolServletConfigurator</servlet-name> <servlet-class>org.logicalcobwebs.proxool.configuration.ServletConfigurator</servlet-class> <init-param> <param-name>xmlFile</param-name> <param-value>WEB-INF/proxool.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>proxool</servlet-name> <servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class> </servlet> <servlet> <servlet-name>context</servlet-name> <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> 其它的内容就不贴了,有需要的可以留言。