The prefix "tx" for element "tx:advice" is not bou

The prefix "tx" for element "tx:advice" is not bound

这个错误的原因很简单是:

我们在定义申明AOP的时候。。没有加载schema。

具体表现如下:

<beans>

<tx:advice id="txAdvice" transaction-manager="transactionManager">   
     <tx:attributes>   
         <tx:method name="get*" read-only="true"/>   
         <tx:method name="*" propagation="REQUIRES_NEW" rollback-for="Exception"/>   
     </tx:attributes>   
 </tx:advice>

<!-- aop代理设置-->   
 <aop:config proxy-target-class="true">   
....

</aop:config>

</beans>

这时会抛出异常不认<TX>标签。。起先还以为是没有加载JAR包呢。。

后来读AOP文档才发现<beans>中要加入“xmlns:aop”的命名申明,并在“xsi:schemaLocation”中指定aop配置的schema的地址

配置文件如下:

<?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:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans 
                     http://www.springframework.org/schema/beans/spring-beans.xsd 
                     http://www.springframework.org/schema/tx 
                     http://www.springframework.org/schema/tx/spring-tx.xsd 
                     http://www.springframework.org/schema/aop 
                     http://www.springframework.org/schema/aop/spring-aop.xsd">

这些才是最关键的地方。。后面的配置不变。。。。

希望能帮助别人解决此类的小问题

The prefix "tx" for element "tx:advice" is not bou

时间: 2024-12-11 17:14:08

The prefix "tx" for element "tx:advice" is not bou的相关文章

The prefix &quot;tx&quot; for element &quot;tx:annotation-driven &quot; is not bound

The prefix "tx" for element "tx:advice" is not bound 这个错误的原因很简单是: 我们在定义申明AOP的时候..没有加载schema. <beans>中要加入“xmlns:aop”的命名申明,并在“xsi:schemaLocation”中指定aop配置的schema的地址 配置文件如下: <?xml version="1.0" encoding="UTF-8"

The prefix &quot;aop&quot; for element &quot;aop:aspectj-autoproxy&quot; is not bound.

在使用spring  aop的时候报错了:The prefix "aop" for element "aop:aspectj-autoproxy" is not bound.原因是有一些地址没有被引入: 以下是一个完整配置AOP的例子. 首先是文件项目结构: SpringAOPTest.java import java.util.ArrayList; import java.util.List; import org.junit.Test; import org.s

The prefix &quot;mvc&quot; for element &quot;mvc:annotation-driven&quot; is not bound 异常

使用STS或者eclipse 开发SpringMVC应用 时,我靠..有个小小的东西没注意搞了半天, STS在创建SpringMVC工程时,自动生成了Dispatcher的配置文件,然后看教程时,使用了<mvc:annotation-driven> 注解配置 但是自动生成的xml里呢有一个<annotation-driven>, 挺疑惑的,以为mvc约束文件版本不对,所以配置了很久的本地约束,仍然没有用 后来决定仔细看看什么问题,通过代码排版对齐,发现了.....靠,前缀也是需要配

Spring配置文件标签报错:The prefix &quot;XXX&quot; for element &quot;XXX:XXX&quot; is not bound. .

例如:The prefix "context" for element "context:annotation-config" is not bound. 这种情况是因为没有申明该标签,然后就使用了.解决方发是,在配置文件头部加入相应的信息即可( 即xmlns:context="http://www.springframework.org/schema/context"). 这种情况是因为没有申明该标签,然后就使用了.解决方发是,在配置文件头部加

java错误-The prefix &quot;aop&quot; for element &quot;aop:aspectj-autoproxy&quot; is not bound.

配置springmvc的aop时出错: 当我向配置文件中添加:<aop:aspectj-autoproxy proxy-target-class="true"/> 时出错: The prefix "aop" for element "aop:aspectj-autoproxy" is not bound. org.springframework.beans.factory.xml.XmlBeanDefinitionStoreExcep

ssm-异常:The prefix &quot;aop&quot; for element &quot;aop:config&quot; is not bound.

今天在搭建ssm环境时出现异常:The prefix "aop" for element "aop:config" is not bound. 原因:applicationContext.xml文件头没有添加 xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/aop

The prefix &quot;mvc&quot; for element &quot;mvc:annotation-driven&quot; is not bound 的解决方法

添加 xmlns:mvc="http://www.springframework.org/schema/mvc" http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd

tx:advice

1 <tx:advice id="txAdvice" transaction-manager="transactionManager"> 2 <tx:attributes> 3 <tx:method name="get*" propagation="SUPPORTS" isolation="DEFAULT" 4 read-only="true" />

Spring4 -12 -声明式事务及完整的XML配置文件信息 -声明式事务中的相关属性(tx:advice的标签)

1.编程式事务: 1.1由程序员编程事务控制代码. 1.2OpenSessionInView 就属于编程式事务: session.commit()和rollback() 2.声明式事务: 2.1事务控制代码已经由spring 写好.程序员只需要声明出哪些方法需要进行事务控制和如何进行事务控制. 3.声明式事务都是针对于ServiceImpl 类下方法的. 4.事务管理器基于通知(advice)的. 5.在spring 配置文件中配置声明式事务 完整地XML配置文件信息: <context:pro