SSH整合(注解方式)dataSource配置defaultAutoCommit启动报错,求解答

在采用注解方式进行SSH整合时,遇到dataSource配置默认autoCommit属性导致启动异常。详细表现为bean创建过程中的setter注入问题,涉及nested exception。本文将探讨这个问题的原因及解决方法。
摘要由CSDN通过智能技术生成
spring配置文件
<?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:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans  
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
           http://www.springframework.org/schema/context  
           http://www.springframework.org/schema/context/spring-context-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">   
      
    <bean id="configBean" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
        <property name="location">  
            <value>classpath:jdbc.properties</value>  
        </property>  
    </bean>  
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">  
        <property name="driverClassName" value="${db.driverClassName}" />  
        <property name="url" value="${db.url}" />  
        <property name="username" value="${db.username}" />  
        <property name="password" value="${db.password}" />  

<!--当写上下面这段时 启动就报错 -->
        <property name="defaultAutoCommit" value="false" />
	<property name="maxActive" value="150" />
        <property name="maxIdle" value="100" />
        <property name="maxWait" value="60000" />
        <property name="minIdle"  value="5" />
        <property name="testOnBorrow" value="true"/>
        <property name="testWhileIdle" value="true"/> 
        <property name="validationQuery" value="select 1 from dual" />



 </bean>  
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">  
        <property name="dataSource" ref="dataSource" />  
        <property name="hibernateProperties">  
            <props> 
            <!--  
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>  
			 --> 
			 	<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>              
                <prop key="hibernate.show_sql">true</prop>  
                <prop key="hibernate.query.factory_class">
					org.hibernate.hql.classic.ClassicQueryTranslatorFactory
				</prop>
            </props>  
        </property>  
        <property name="mappingResources">  
            <list>  
                <value>com/yeshun/bean/User.hbm.xml</value>  
            </list>  
        </property>  
    </bean>  

 <!-- 采用注释的方式配置bean -->  
    <context:annotation-config />  
    <context:component-scan base-package="com.yeshun" />  
    
  
    <!-- 采用注释的方式配置 aop -->  
    <aop:aspectj-autoproxy /> 
    
     <!-- 采用annotation的方式配置事务 -->  
    <tx:annotation-driven transaction-manager="transactionManager" />  
  
    <!--采用配置文件的方式配置事务 -->  
  
    <!-- 配置一个事务切面 -->  
    <aop:config>  
        <aop:pointcut expression="execution(* com.yeshun.service.*.*(..))"  
            id="txManager" />  
        <aop:advisor advice-ref="txAdvice" pointcut-ref="txManager" />  
    </aop:config>  
  
    <!-- 配置事务的具体使用方式 -->  
    <tx:advice id="txAdvice" transaction-manager="transactionManager">  
        <tx:attributes>  
            <tx:method name="get*" read-only="true" />  
            <tx:method name="*" propagation="REQUIRED" />  
        </tx:attributes>  
    </tx:advice>  

    
    <!--jdbcTemplate-->
	<bean id="jdbcTemplate"
		class="org.springframework.jdbc.core.JdbcTemplate">
		<property name="dataSource" ref="dataSource" />
	</bean>

	<!--transactionManager-->
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	 <!-- 配置hibernateTemplate模板 -->  
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.Hibern
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值