日期:2014-05-19  浏览次数:20719 次

SPRING MVC + IBATIS 问题
代码段一:
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans default-lazy-init="true">
<import resource="classpath:/META-INF/ac_database_db.xml"/>
<bean id="crdao" class="com.estock.database.car.CarDaoImpl">
<property name="dataSource" ref="dataSource_database"></property>
<property name="sqlMapClient" ref="sqlMapClient_database"></property>
</bean>


</beans>


代码段二:
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans default-lazy-init="true">
<!-- 数据源 -->
<bean id="dataSource_database" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
<property name="url" value="jdbc:oracle:thin:@192.168.1.250:1521:YIDEEORC"></property>
<property name="username" value="estock"></property>
<property name="password" value="estock"></property>
        <property name="initialSize" value="10"/>
        <property name="maxActive" value="10"/>
        <property name="maxIdle" value="10"/>
        <property name="maxWait" value="1000"/>
   </bean>

   <!-- 事务管理器 -->
<bean id="transactionManager_database" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource_database" />
</bean>
   <!-- 事务拦截器 -->
  <bean id="transactionInterceptor_database" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager_database" />
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED,-Throwable,ISOLATION_READ_COMMITTED</prop>
</props>
</property>
</bean>
<!-- 事务代理 -->
<bean id="transactionProxy_database" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="interceptorNames">
<list>
<value>transactionInterceptor_database</value>
</list>
</property>
</bean>

<!-- IBatis配置 -->
   <bean id="lobHandler_database" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true" /> 
<bean id="sqlMapClient_database" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:/META-INF/sqlmap-database.xml" />
<property name="dataSource" ref="dataSource_database" ></property>
<property name="lobHandler" ref="lobHandler_database"></property>
</bean>