切入点内的Spring AOP

切入点内的Spring AOP,第1张

概述package com.vanilla.daoService; @Repository('daoService') public class DaoServiceImpl implements DaoService { @Override public String addStudent(Student s

package com.vanilla.daoService;    @Repository("daoService")    public class DaoServiceImpl implements DaoService {        @OverrIDe        public String addStudent(Student student) {            //saving new user             }        @OverrIDe        public String updateStudent(Student student) {            //update new user             }        @OverrIDe        public String getStudent(String ID) {            //update new user             }    }

我的业务逻辑课:

package com.vanilla.blService;@Service("blService") public class BlServiceImpl implements BlService {    @autowired    DaoService daoService;@OverrIDepublic voID updateStudent(String ID){   Student s = daoService.getStudent(ID);   set.setAddress(address);   daoService.updateStudent(s);}}

现在,我要评估在每个业务逻辑功能(daoservice.*)中执行的所有方法的执行情况

我创建我的Aspect类

@Aspectpublic class BlServiceProfiler {    @pointcut("within(com.vanilla.blService.BlService.*)")    public voID businessLogicmethods(){}      @Around("businessLogicmethods()")      public Object profile(ProceedingJoinPoint pjp) throws Throwable {          long start = System.currentTimeMillis();          System.out.println("Going to call the method " + pjp.toShortString());          Object output = pjp.proceed();          System.out.println("Method execution completed.");          long elapsedtime = System.currentTimeMillis() - start;          System.out.println(pjp.toShortString()+" execution time: " + elapsedtime + " milliseconds.");          return output;      }}

不幸的是,什么都没有发生.我认为我的@pointcut定义不正确,我该如何正确执行?最佳答案您可能想要这样:

@pointcut("within(com.vanilla.blService.BlService+)")public voID businessLogicmethods(){}

BlService表示BlService及其所有子类/实现类. 总结

以上是内存溢出为你收集整理的切入点内的Spring AOP 全部内容,希望文章能够帮你解决切入点内的Spring AOP 所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/1233966.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存