Spring aop:config
Spring aop:config
我刚开始使用 Spring 框架...首先出现这个错误
The prefix aop for element aop config is not bound
然后我将以下内容添加到 Spring.xml
<beans xmlns="http://www.springframework.org/schema/beans"
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.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
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
现在还是有错误
Error occured processing XML 'org/springframework/aop/aspectj/AspectJMethodBeforeAdvice'
这是我的完整 xml 文件
<?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: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.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
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<aop:config>
<aop:aspect ref="audience">
<aop:before pointcut="execution(* com.uttara.spring.Performer.perform(..))"
method="takeSeats" />
<aop:before pointcut="execution(* com.uttara.spring.Performer.perform(..))"
method="switchOffPhones" />
<aop:after-returning
pointcut="execution(* com.uttara.spring.Performer.perform(..))"
method="clap" />
<aop:after-throwing
pointcut="execution(* com.uttara.spring.Performer.perform(..))"
method="boo" />
</aop:aspect>
</aop:config>
<bean id="duke" class="com.uttara.spring.Juggler">
<constructor-arg value="15"></constructor-arg>
</bean>
<bean id="poem" class="com.uttara.spring.EnglishPoem"></bean>
<bean id="hans" class="com.uttara.spring.PoeticJuggler">
<constructor-arg value="15"></constructor-arg>
<constructor-arg ref="poem"></constructor-arg>
</bean>
<bean id="audience" class="com.uttara.spring.Audience"></bean>
</beans>
请帮忙!
我完全不知道。
我有几个库文件。我不知道他们到底是做什么的。是否缺少图书馆?是什么导致了这些错误?我该如何解决?
(...)
是为切入点指定参数(零个或多个)的不正确方式。尝试在切入点表达式中用 (..)
替换。
使用spring需要很多库文件。 Aspectjrt
、Aspectj-weaver
、aop-alliance
是一些,我们没有得到 spring 依赖 jar 文件。我们已经成功下载并添加到基于 运行 spring 的应用程序的类路径中。
我刚开始使用 Spring 框架...首先出现这个错误
The prefix aop for element aop config is not bound
然后我将以下内容添加到 Spring.xml
<beans xmlns="http://www.springframework.org/schema/beans"
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.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
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
现在还是有错误
Error occured processing XML 'org/springframework/aop/aspectj/AspectJMethodBeforeAdvice'
这是我的完整 xml 文件
<?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: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.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
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<aop:config>
<aop:aspect ref="audience">
<aop:before pointcut="execution(* com.uttara.spring.Performer.perform(..))"
method="takeSeats" />
<aop:before pointcut="execution(* com.uttara.spring.Performer.perform(..))"
method="switchOffPhones" />
<aop:after-returning
pointcut="execution(* com.uttara.spring.Performer.perform(..))"
method="clap" />
<aop:after-throwing
pointcut="execution(* com.uttara.spring.Performer.perform(..))"
method="boo" />
</aop:aspect>
</aop:config>
<bean id="duke" class="com.uttara.spring.Juggler">
<constructor-arg value="15"></constructor-arg>
</bean>
<bean id="poem" class="com.uttara.spring.EnglishPoem"></bean>
<bean id="hans" class="com.uttara.spring.PoeticJuggler">
<constructor-arg value="15"></constructor-arg>
<constructor-arg ref="poem"></constructor-arg>
</bean>
<bean id="audience" class="com.uttara.spring.Audience"></bean>
</beans>
请帮忙! 我完全不知道。 我有几个库文件。我不知道他们到底是做什么的。是否缺少图书馆?是什么导致了这些错误?我该如何解决?
(...)
是为切入点指定参数(零个或多个)的不正确方式。尝试在切入点表达式中用 (..)
替换。
使用spring需要很多库文件。 Aspectjrt
、Aspectj-weaver
、aop-alliance
是一些,我们没有得到 spring 依赖 jar 文件。我们已经成功下载并添加到基于 运行 spring 的应用程序的类路径中。