例如,被切入的类中有selectPro(…),insertPro(…),insertProductImg(…),updateProductImg(…),updateProduct(…)这几个方法,但是我只想切入insertPro(…)和updateProduct(…)这两个方法,
这里使用最常见的execution(* edu.learning.tyh.manager.service.*. insert*(…))这种方法已经不满足了要求了,我又不想改方法名,在网上找了半天的解决办法,最后还是参考了springAOP的官方文档,使用连接符去连接切入点表达式的方法解决。
即expression=“execution(* edu.learning.tyh.manager.service.impl.ProductServiceImpl.insertProduct(…)) or execution(* edu.learning.tyh.manager.service.impl.ProductServiceImpl.updateProduct(…))”(注意:这里是"or"连接而不是"and",这个地方坑了我好久,捂脸)
虽然这样看起来挺麻烦的,但又没找到更方便的方法(ps:有看到的大佬知道更方便的解决方法的话欢迎评论!感谢)