applicationContext.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!-- jdbc-odbc桥连 -->
<beans>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config/jdbc.properties</value>
</list>
</property> </bean>
<!--单例数据库连接
<bean id="dataSource"
class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
destroy-method="close">
<property name="url">
<value>${database.url}</value>
</property>
<property name="driverClassName">
<value>${database.driver}</value>
</property>
<property name="username">
<value>${database.user}</value>
</property>
<property name="password">
<value>${database.password}</value>
</property>
<property name="autoCommit">
<value>true</value>
</property>
</bean>
-->
<!-- c3p0 对应数据库的数据连接池 -->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="jdbcUrl">
<value>${database.url}</value>
</property>
<property name="driverClass">
<value>${database.driver}</value>
</property>
<property name="user">
<value>${database.user}</value>
</property>
<property name="password">
<value>${database.password}</value>
</property>
</bean> <!--apache 对应数据库的数据连接池
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="url">
<value>${database.url}</value>
</property>
<property name="driverClassName">
<value>${database.driver}</value>
</property>
<property name="username">
<value>${database.user}</value>
</property>
<property name="password">
<value>${database.password}</value>
</property>
<property name="defaultAutoCommit">
<value>true</value>
</property>
</bean> --> <!-- 配置事务管理 -->
<!-- 不管采用哪种方法 下面的这个bean都是必须的 它是事物管理器-->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean> <!-- 事务的属性 -->
<bean id="transactionAttributeSource"
class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="target">
<ref bean="playerServiceTarget" />
</property>
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributeSource">
<ref bean="transactionAttributeSource" />
</property>
</bean> <bean id="jdbcTemplate"
class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="playerDaoJdbc" class="org.vieri.daoJdbc.PlayerDaoJdbc">
<property name="jdbcTemplate">
<ref bean="jdbcTemplate" />
</property>
</bean>
<bean id="playerServiceTarget"
class="org.vieri.service.IPlayerServiceImpl" singleton="false">
<property name="playerDao">
<ref bean="playerDaoJdbc" />
</property>
</bean>
</beans>
解决方案 »
- 大牛请进
- 请问为什么我连接了数据库以后,然后导出的Excel表之后,出现的只有数据那一列的第一个数据呢
- weblogic JTA 两阶段提交,JTA总是超时
- JNDI连接Oracle数据库遇到问题
- 最近做了个javaweb应用,我用ie8做的测试,,有些页面不兼容
- 请教关于LOG4J的DailyRollingFileAppender不能改名的问题,急
- 小弟刚学java与struts,对一小段代码不清楚,还请高人指点,问题会者不难,在线等,决解马上解贴
- 发送广播消息
- (200)帮帮我!Excel中文问题??在线等待!!!
- 一个极其菜的问题:JAVA,VISUAL J++,JAVA SCRIPT,EJB,它们之间到底有什么关系,谢谢!
- 求java&xml的书籍
- WebLogic 9 中部署项目中的问题
http://struts.apache.org/2.1.2/docs/struts-2-spring-2-jpa-ajax.html
我的也是这样 用了这个就不好使 并且事务提交总是有问题 搞不明白了