weixin_42360958 2010-03-17 21:11
浏览 322
已采纳

spring2+dpcp配置出现异常:急解决

spring的applicationContext配置文件如下
[code="xml"]
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
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-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" >

<context:property-placeholder location="classpath:jdbc.properties"  />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${driverClassName}" />
    <property name="url" value="${url}" />
    <property name="username" value="${username}" />
    <property name="password" value="${password}" />
    <!-- 连接池启动时的初始值 -->
    <property name="initialSize" value="${initialSize}" />
    <!-- 连接池最大值 -->
    <property name="maxActive" value="${maxActive}" />
    <!-- 最大空闲值,当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 -->
    <property name="maxIdle" value="${maxIdle}" />
    <!-- 最小空闲值,当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰时来不及 -->
    <property name="minIdle" value="${minIdle}" />
</bean>
<!-- 采用注解事务 -->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSourceName" ref="dataSource"></property>
</bean>
<!-- 采用@Transaction注解方式使用事务 -->
<tx:annotation-driven transaction-manager="txManager" />


[/code]

启动tomcat的时候报了异常
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'dataSourceName' of bean class [org.springframework.jdbc.datasource.DataSourceTransactionManager]: Bean property 'dataSourceName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'dataSourceName' of bean class [org.springframework.jdbc.datasource.DataSourceTransactionManager]: Bean property 'dataSourceName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

...........
请求朋友帮忙,赶紧解决吧

  • 写回答

5条回答 默认 最新

  • suziwen 2010-03-17 21:50
    关注

    你少加了sitemesh的相关包引用?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题