gpt4 book ai didi

java - Spring aop :config

转载 作者:行者123 更新时间:2023-12-01 11:06:45 28 4
gpt4 key购买 nike

我是 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需要大量的库文件。 AspectjrtAspectj-weaveraop-alliance 是其中一些,我们没有将其作为 Spring 依赖 jar 文件获得。我们已经下载并添加到类路径以成功运行基于 spring 的应用程序。

关于java - Spring aop :config,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32871418/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com