【说明】

  1、使用spring版本:4.0.4

  2、springAOP相关依赖包:

    1)aopalliance-1.0.jar

    2)aspectjweaver-1.8.9.jar

    3)aspectjrt-1.8.9.jar

  3、分析:

    1)当切面类的方法上通知注解直接输入切入点表达式时,没有报错。切面类代码如下:

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.hibernate.Transaction;
import org.springframework.stereotype.Component; @Component("myTransaction")
@Aspect
public class MyTransaction extends HibernateUtil{ private Transaction transaction; @Before("execution(* net.fifteenho.spring.aop.annotation.PersonDaoImpl.*(..))")
public void beginTransaction() {
transaction = sessionFactory.getCurrentSession().beginTransaction();
} @AfterReturning("execution(* net.fifteenho.spring.aop.annotation.PersonDaoImpl.*(..))")
public void commit() {
transaction.commit();
}
}

    2)当切面类的方法上通知注解引入定义的切入点,报错error at ::0 can't find referenced pointcut。切面类代码如下:

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.hibernate.Transaction;
import org.springframework.stereotype.Component; @Component("myTransaction")
@Aspect
public class MyTransaction extends HibernateUtil{ @Pointcut("execution(* net.fifteenho.spring.aop.annotation.PersonDaoImpl.*(..))")
private void mypc(){} private Transaction transaction; @Before("mypc()")
public void beginTransaction() {
transaction = sessionFactory.getCurrentSession().beginTransaction();
} @AfterReturning("mypc()")
public void commit() {
transaction.commit();
}
}

  4、本人解决方法:aspectjweaver.jar替换较新的aspectjweaver-1.8.9.jar

  5、报错原因:springAOP依赖jar版本过低。

【springAOP相关依赖包下载maven】

    <!-- https://mvnrepository.com/artifact/aopalliance/aopalliance -->
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
</dependency> <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.9</version>
</dependency> <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjrt -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.9</version>
</dependency>

  

springAOP注解方式定义切入点报错error at ::0 can't find referenced pointcut的更多相关文章

  1. Java入门到精通——调错篇之Spring2.5利用aspect实现AOP时报错: error at ::0 can't find referenced pointcut XXX

    一.问题描述及原因. 利用Aspect注解实现AOP的时候出现了error at ::0 can't find referenced pointcut XXX.一看我以为注解写错了,结果通过查询相关资 ...

  2. springAOP配置XML方式配置切面报错error at ::0 formal unbound in pointcut

    [错误配置文件] <aop:config> <aop:pointcut expression="execution(* net.fifteenho.service.impl ...

  3. AspectJ报错:error at ::0 can't find referenced pointcut XXX

    今天在使用AspectJ进行注解切面时,遇到了一个错误. 切点表达式就是无法识别——详细报错信息如下: Exception in thread "main" org.springf ...

  4. 项目报错 java lang illegalargumentexception error at 0 can t find referenced pointcut

    出现error at ::0 can't find referenced pointcut...这样的错误原因是:如果你用的JDK版本是1.6的话,而引用的aspectjrt.jar是spring-2 ...

  5. error at ::0 can't find referenced pointcut解决办法(转载)

    原文:http://blog.sina.com.cn/s/blog_9ecb0d9d0101fheg.html Spring中采用annotation的方式实现AOP代理,运行测试代码时抛出以下异常: ...

  6. 解决:“java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut myMethod”问题!

    Spring版本:2.5.6 AspectJ是Spring自带的lib. Jdk版本:1.7.0_17 在配置没问题的情况下,报:java.lang.IllegalArgumentException: ...

  7. error at ::0 can't find referenced pointcut performance

    严重: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support. ...

  8. error at ::0 can't find referenced pointcut...解决方法

    error at ::0 can't find referenced pointcut...解决方法 学习了:http://dyldragon.iteye.com/blog/512612 升级aspe ...

  9. SpringAOP注解报错:java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut selectAll

    原因 我使用的aspectjweaver.jar版本是1.5.1,版本过低,导致报错. 需要下载高本版的aspectjweaver.jar. 解决办法 在这里下载:https://mvnreposit ...

随机推荐

  1. vuex与redux,我们都一样

    vuex与redux的主要区别: redux:生成的全局数据流是通过每个组件的props逐层传递到各个子组件的,通过@connect装饰器绑定在this.props上面. vuex :生成的全局数据则 ...

  2. 让元素div消失在视野中

    让元素div消失在视野中1.position:absolute/relative/fixed + 方位 top/bottom/left/right: -9999px2.display:none3.vi ...

  3. 最高的奖励 - 优先队列&贪心 / 并查集

    题目地址:http://www.51cpc.com/web/problem.php?id=1587 Summarize: 优先队列&贪心: 1. 按价值最高排序,价值相同则按完成时间越晚为先: ...

  4. Python学习笔记之map、zip和filter函数

    这篇文章主要介绍 Python 中几个常用的内置函数,用好这几个函数可以让自己的代码更加 Pythonnic 哦 1.map map() 将函数 func 作用于序列 seq 的每一个元素,并返回处理 ...

  5. python3连接mysql 稍微进阶 + 日期处理

    1.踩了个操作中文的坑,结果发现之前的文章中有强调了,在连接处加:charset="utf8" conn = pymysql.connect(host = '127.0.0.1', ...

  6. Glossary in Turbulence

    Table of Contents 1. Concepts/Glossary 1.1. Turbulent eddy viscosity ,μt 1.2. Turbulent kinetic ener ...

  7. 爬楼梯,N级楼梯有多少种走法?

    https://blog.csdn.net/tcpipstack/article/details/45173685 一个人爬楼梯,一步可以迈一级,二级,三级台阶,如果楼梯有N级,要求编写程序,求总共有 ...

  8. 百练4103:踩方格(DFS)

    描述 有一个方格矩阵,矩阵边界在无穷远处.我们做如下假设:a.    每走一步时,只能从当前方格移动一格,走到某个相邻的方格上:b.    走过的格子立即塌陷无法再走第二次:c.    只能向北.东. ...

  9. HDU 1018 阶乘数的位数

    题目大意: 将一个数开阶乘后得到的值,来求这个值的位数 n! = 1*2*3*4...*n 对于求一个数的位数的方法为ans = lg(n!) + 1 那么就可以看作 ans = lg(1) + lg ...

  10. C语言编程规范试题

    C语言编程规范试题 [说明]: 1.本试题中不考虑头文件引用问题(假定已经包含正确的头文件),C语言的标准函数都可用: 2.如果不特别说明,假定程序运行环境为:操作系统Windows 2000, VC ...