tmh7788 2010-10-05 12:32
浏览 666
已采纳

Spring初学者配置AOP总是错误Unable to locate Spring NamespaceHandler for XML schema namesp

源码:

package stu.liuli.aspect;

public interface ArithmeticCalculator {
void add(int i,int j);
}

package stu.liuli.aspect;

import org.springframework.stereotype.Component;

@Component("arithmeticCalculator")
public class ArithmeticCalculatorImp implements ArithmeticCalculator {

@Override
public void add(int i, int j) {
    int result = i + j ;
    System.out.println("add :" + result);
}

}

package stu.liuli.aspect;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LoggingAspect {
@Before(value = "excution(* stu.liuli.aspect.*.*(..)")
public void beforeMethodLogging(){
System.out.println("before method...");
}
}

XML文件:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
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/context
http://www.springframework.org/schema/context/spring-context-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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

aop:aspectj-autoproxy/

/context:component-scan

jar包:用MyEclipse的Spring支持导入了Spring 2.5 Core Librarier,然后自己导入了aspectjrt.jar,aspectjweaver.jar,cglib-nodep-2.1_3.jar

然后运行时候总是报异常:Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/aop]
Offending resource: class path resource [applicationContext.xml]

我也去网上找了相关的解决方法好像都不行。。。

  • 写回答

2条回答 默认 最新

  • freshman_2007 2010-10-05 14:57
    关注

    1、在applicantContext.xml中添加如下语句:
    试试看。

    2、检查JAR包,看是否有冲突。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题