Exception in thread "main" org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public int aoppoint.User.getUsername()
at org.springframework.aop.framework.CglibAopProxy.processReturnType(CglibAopProxy.java:391)
at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:82)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:675)
at aoppoint.User$$EnhancerBySpringCGLIB$$ab381b5d.getUsername(<generated>)
at aoppoint.Console.main(Console.java:25)

  public void logAround(ProceedingJoinPoint joinPoint) {
System.out.println("userbean方法执行之前 Around,切入的名字 : " + joinPoint.getSignature().getName());
try {
joinPoint.proceed(); //阻塞
System.out.println("userbean方法执行之后 Around,切入的名字 : " + joinPoint.getSignature().getName());
} catch (Throwable throwable) {
throwable.printStackTrace();
System.out.println("userbean方法执行出错 Around,切入的名字 : " + joinPoint.getSignature().getName());
}
}

  后来发现是环绕监听会对有返回值的方法做处理,所以需要对 logAround方法修改一下,让它有一个返回值,返回object就可以了

public Object logAround(ProceedingJoinPoint joinPoint) {
System.out.println("userbean方法执行之前 Around,切入的名字 : " + joinPoint.getSignature().getName());
Object result=null;
try {
result = joinPoint.proceed();//阻塞
System.out.println("userbean方法执行之后 Around,切入的名字 : " + joinPoint.getSignature().getName());
} catch (Throwable throwable) {
throwable.printStackTrace();
System.out.println("userbean方法执行出错 Around,切入的名字 : " + joinPoint.getSignature().getName());
}
return result;
}

最新文章

  1. 解析C#类中的构造函数
  2. Redis系列三之持久化
  3. c# dynamic动态类型和匿名类
  4. POJ 3225 (线段树 区间更新) Help with Intervals
  5. [Locked] Range Sum Query 2D - Mutable
  6. C#泛型比较大小
  7. boost::share_ptr用法
  8. jq 测试是否到页面最底端
  9. CentOS6 图形界面(gnome)安装,使用vnc进行远程连接
  10. vue中显示静态图片怎么引用
  11. Oracle和Mysql的安装
  12. rest_framework中视图相关
  13. linux下GCC编译文件
  14. 分布式任务调度系统xxl-job搭建
  15. ERP合同管理流程查询(三十一)
  16. Azure Document DB Repository 的实现
  17. java.io.PrintWriter 中 write() 与 print() 的区别
  18. eclipse怎么导出可执行jar包
  19. PL/SQL 编程(二)
  20. linux 基本命令___0003 字符串处理和yum安装软件的路径

热门文章

  1. python 字符类型
  2. 数组copy
  3. Compile pam with pam_cracklib.so
  4. [Day8] eclipse
  5. pandas 2
  6. 最全的MonkeyRunner自动化测试从入门到精通(4)
  7. iptables 分析(1)
  8. jsp (二) 练习
  9. caffe中的卷积
  10. linux----------阿里云服务器使用过程中遇到的各种问题以及解决渠道