读书人

Oracle 数据源的配备。在Spring环境中

发布时间: 2013-03-10 09:38:39 作者: rapoo

Oracle 数据源的配置。在Spring环境中


第一种 采用JDBC配置文件。


<?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:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:jdbc="http://www.springframework.org/schema/jdbc"xmlns:ehcache="http://www.springmodules.org/schema/ehcache"xmlns:context="http://www.springframework.org/schema/context"xmlns:flex="http://www.springframework.org/schema/flex"xsi:schemaLocation="             http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd             http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd             http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd      http://www.springframework.org/schema/flex      http://www.springframework.org/schema/flex/spring-flex-1.0.xsd      http://www.springmodules.org/schema/ehcache http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd"default-autowire="byName"><context:annotation-config /><bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"><property name="jndiName"><value>KINGHONG</value></property></bean><bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"><property name="dataSource"><ref bean="dataSource" /></property></bean><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource" /></bean><!-- 需要事务控制的业务方法配置 --><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="get*" read-only="true" /><tx:method name="find*" read-only="true" /><tx:method name="query*" read-only="true" /><tx:method name="select*" read-only="true" /><tx:method name="count*" read-only="true" /><tx:method name="*" rollback-for="Exception" /></tx:attributes></tx:advice><!-- 事务控制拦截器 --><aop:config proxy-target-class="true"><aop:advisorpointcut="execution(* *..service.impl.*(..)) or execution(* *..service..*ServiceImpl.*(..))"advice-ref="txAdvice" /></aop:config><bean id="sqlSessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean"><property name="configLocation"value="/WEB-INF/conf/mybatis/mybatis-config.xml" /><property name="mapperLocations"value="classpath*:/org/topcheer/biz/sys/xml/*.xml" /><property name="dataSource" ref="dataSource" /></bean></beans>


读书人网 >编程

热点推荐