spring访问数据库
来源:互联网 发布:网络与新媒体研究生吧 编辑:程序博客网 时间:2024/05/16 14:26
以下是配置一个完整的配置文件,有时间再详细讲解
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <bean id="dataSource" class="net.bull.javamelody.SpringDataSourceFactoryBean"> <property name="targetName" value="_dataSource" /> </bean> <bean id="_dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass"> <value>${jdbc.driverClassName}</value> </property> <property name="jdbcUrl"> <value>${jdbc.url}?autoReconnectForPools=true&useUnicode=true&characterEncoding=utf8&readOnly=true </value> </property> <property name="user"> <value>${jdbc.username}</value> </property> <property name="password"> <value>${jdbc.password}</value> </property> <property name="initialPoolSize"> <value>${jdbc.initialPoolSize}</value> </property> <property name="minPoolSize"> <value>${jdbc.minPoolSize}</value> </property> <property name="maxPoolSize"> <value>${jdbc.maxPoolSize}</value> </property> <property name="maxIdleTime"> <value>${jdbc.maxIdleTime}</value> </property> <property name="acquireIncrement"> <value>${jdbc.acquireIncrement}</value> </property> <property name="acquireRetryAttempts"> <value>${jdbc.acquireRetryAttempts}</value> </property> <property name="acquireRetryDelay"> <value>${jdbc.acquireRetryDelay}</value> </property> <property name="maxStatements"> <value>${jdbc.maxStatements}</value> </property> <property name="maxStatementsPerConnection"> <value>${jdbc.maxStatementsPerConnection}</value> </property> <property name="checkoutTimeout"> <value>${jdbc.checkoutTimeout}</value> </property> <property name="breakAfterAcquireFailure"> <value>${jdbc.breakAfterAcquireFailure}</value> </property> </bean><!--事务管理器,对事务进行管理--> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean><!--让spring来管理SqlMapClient对象--> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation"> <value>classpath:sqlmap-config.xml</value> </property> <property name="dataSource" ref="dataSource" /> </bean> <bean id="sqlMapTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate"> <property name="sqlMapClient" ref="sqlMapClient" /> </bean> <bean id="baseDao" class="com.***.***.dao.BaseDao" abstract="true"> <property name="sqlMapTemplate" ref="sqlMapTemplate" /> </bean> <bean id="userResourceDao" class="com.***.***.dao.UserResourceDao"> <property name="sqlMapTemplate" ref="sqlMapTemplate"></property> </bean> <bean id="platformDao" class="com.***.***.dao.PlatformDao" parent="baseDao" /> <tx:advice id="transactionManagerAdivice" transaction-manager="txManager"> <tx:attributes> <tx:method name="*" isolation="READ_COMMITTED" propagation="REQUIRED" rollback-for="java.lang.RuntionException" /> </tx:attributes> </tx:advice><!-- 配置哪些类的方法需要进行事务管理 --> <aop:config> <aop:pointcut expression="execution(* com.***.***.service.ApplyAppService.*(..))" id="applyAppServicePc" /> <aop:advisor advice-ref="transactionManagerAdivice" pointcut-ref="applyAppServicePc" /> </aop:config></beans>
0 0
- spring 之 访问数据库
- spring访问数据库
- Spring+Hibernate多线程访问数据库
- Spring访问数据库(oracle)配置
- 使用spring-jdbc访问数据库
- 013. Spring JdbcTemplate访问数据库
- 014. Spring JdbcDaoSupport访问数据库
- 015. Spring NamedParameterJdbcTemplate访问数据库
- Spring访问数据库(oracle)配置
- 3、spring-boot访问数据库
- 小曹学spring--使用Spring JDBC访问数据库
- Spring JDBC-使用Spring JDBC访问数据库
- Spring DAO(2):Spring JDBC 访问数据库
- spring jdbc模板 数据库访问例子
- spring+hibernate 访问数据库的方法
- Spring 使用JDBC对数据库进行访问
- spring的持久化数据库访问
- spring 数据库访问之ibatis(一)
- 模型的把控
- STL_Sequence_大小写英文字母和数字进栈输出显示
- HashMap collision problem
- 微派第四届企业微信营销培训成功举行
- 一些笔记
- spring访问数据库
- delphi 短信猫(SMS)编程总结
- 推理机Jess、Racer、Jena 比较 (转)
- 信息检索之索引压缩
- Setup win32 development environment
- (转)Cocos2d-x加Box2D制作弹弓类游戏
- log4net 发送错误日志到邮箱配置
- python 写的http后台弱口令爆破工具
- 几十个网站后台模板css+div模板收集