在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>
其它的内容就不贴了,有需要的可以留言。
上一篇: ssh 访问不需要密码
推荐阅读
-
web容器中实例化spring相关配置解析
-
Spring Boot中配置文件application.properties使用
-
maven的安装配置以及在IDEA中的配置图文教程
-
在Spring中基于Java类进行配置的完整步骤
-
在Django中同时使用多个配置文件的方法
-
Eclipse中导入Maven Web项目并配置其在Tomcat中运行图文详解
-
在ASP.NET 2.0中操作数据之七十:配置数据库连接和命令等级设置
-
spring 整合 mybatis 中数据源的几种配置方式(总结篇)
-
详解如何在低版本的Spring中快速实现类似自动配置的功能
-
Go语言系列:(1)在VsCode中配置Go的开发环境