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条)

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?