biaoge2000000 2011-05-03 16:45
浏览 282
已采纳

Spring初学者,配置出错,求解决办法。

<?xml version="1.0" encoding="UTF-8" ?>
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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

<!-- 配置数据源 -->
<bean id = "dataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name = "driverClass" value = "com.mysql.jdbc.Driver"/>
    <property name = "jdbcUrl" value = "jdbc:mysql://localhost/db_bbs"/>
    <property name = "user" value = "root"/>
    <property name ="password" value = "cy123"/>
    <property name = "maxPoolSize" value = "40"/>
    <property name = "minPoolSize" value = "1"/>
    <property name = "maxIdleTime" value = "20"/>
</bean>
<!-- 配置对应的事务管理器 -->
<bean id = "transactionManager" class = "org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name = "dataSource" ref = "dataSource"/>
</bean>

<!-- 配置业务逻辑BEAN -->
<bean id = "test" class = "trans.TestImp1">
    <property name = "ds" ref = "dataSource"/>
</bean>

<!-- 配置事务切面bean -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="get*" read-only="true"/>
        <tx:method name="*"/>
    </tx:attributes>
</tx:advice>

<aop:config>
    <aop:pointcut id="addTrans" expression="execution(* trans.*Imp1.*(..))"/>
    <aop:advisor advice-ref="txAdvice" pointcut-ref="addTrans"/>
</aop:config>   

运行时报错如下
schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/tx/spring-tx-2.5.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not xsd:schema.

Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 34 in XML document from class path resource [applicationContext.xml] is invalid; nested

exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:advice'.
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:advice'.

搜索了一下网上的解决办法,都是说在声明那里增加xmlns:tx声明,但我加了还是报这个错误,不知道是怎么回事了.....

  • 写回答

2条回答 默认 最新

  • liukaihandsome 2011-05-03 18:25
    关注

    看看你有没有spring-tx这个jar包

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

报告相同问题?

悬赏问题

  • ¥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时遇到的编译问题