【发布时间】:2015-10-07 15:36:40
【问题描述】:
我是使用 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 新手,请不要从旧的 XML 配置开始。使用 Spring Boot,并使用 start.spring.io 自动生成一个完整的现成包以供使用。