日期:2014-05-18  浏览次数:20792 次

Spring 里面XML配置AOP时 报错
直接发代码  各位帮忙看看

package com.jinoux.personservice;
/**
 * 接口
 * @author Cary
 *
 */
public interface PersonServiceDao {

public void save();

}


package com.jinoux.personservice.impl;

import com.jinoux.personservice.PersonServiceDao;

/**
 * 业务类
 * @author Cary
 *
 */
public class PersonServiceBean implements PersonServiceDao{

public void save() {

System.out.println("save()方法");

}

}


package com.jinoux.personservice;

import org.aspectj.lang.ProceedingJoinPoint;

/**
 * 切面
 * @author Cary
 *
 */
public class MyInterceptor {

public void doAccessCheck(){
System.out.println("前置通知");
}

public void doAfterReturning(){
System.out.println("后置通知");
}

public void doAfter(){
System.out.println("最终通知");
}

public void doAfterThrowing(){

System.out.println("例外通知");
}


public Object doBasicProfiling(ProceedingJoinPoint pjp)throws Throwable{

System.out.println("进入方法");

Object result = pjp.proceed();

System.out.println("退出方法");


return result;

}

}


package junit.test;

import static org.junit.Assert.*;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.jinoux.personservice.PersonServiceDao;

/**
 * 测试
 * @author Cary
 *
 */
public class SpringTest {

@Test
public void test() {

ApplicationContext cxt = new ClassPathXmlApplicationContext("beans.xml");

PersonServiceDao personserivcedao = (PersonServiceDao) cxt.getBean("personservice");

personserivcedao.save();
}

}

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-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/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">


<bean id="personservice" class="com.jinoux.personservice.impl.PersonServiceBean"></bean>
<!-- 把切面交给Bean -->
<bean id="myInterceptor" class="com.jinoux.personser