Exception Spring AOP@未执行后续通知

Exception Spring AOP@未执行后续通知,exception,aop,aspectj,spring-aop,spring-annotations,Exception,Aop,Aspectj,Spring Aop,Spring Annotations,我定义的@Afterhrowing建议没有得到执行。谁能帮我看看吗?下面是我正在使用的代码 Pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/

我定义的@Afterhrowing建议没有得到执行。谁能帮我看看吗?下面是我正在使用的代码

Pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"     
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Test</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SpringAOPAfterThrowsTest</name>
<dependencies>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-core</artifactId>
  <version>3.2.4.RELEASE</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>3.2.4.RELEASE</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-aop</artifactId>
  <version>3.2.4.RELEASE</version>
</dependency>
<dependency>
  <groupId>org.aspectj</groupId>
  <artifactId>aspectjrt</artifactId>
  <version>1.7.3</version>
</dependency>
<dependency>
  <groupId>org.aspectj</groupId>
  <artifactId>aspectjweaver</artifactId>
  <version>1.7.3</version>
</dependency>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.11</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-test</artifactId>
  <version>3.2.4.RELEASE</version>
 </dependency>
</dependencies>
</project>
 <?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"  
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/aop  

http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
    http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util-3.2.xsd">


<aop:aspectj-autoproxy />
<bean id="loggingBean" class="com.aop.test.LoggingAspect" />

</beans>
AOP下的样本类

package com.aop.test;

public class SampleClassUnderAOP {

public void sampleMethod() {
    String str = null;
    System.out.println(str.length());
}

}
testop单元测试类

package com.aop.test;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath:/spring-context.xml" })
public class TestAOP {

    @Test
    public void test() {
        SampleClassUnderAOP sc = new SampleClassUnderAOP();
        sc.sampleMethod();
    }

}

在您的
日志方面
尝试以下操作:

@AfterThrowing(pointcut = "execution(public * com.aop..*(..))", throwing = "e")
删除了
*

@AfterThrowing(pointcut = "execution(public * com.aop..*(..))", throwing = "e")