Code Monkey home page Code Monkey logo

Comments (7)

areyouok avatar areyouok commented on June 19, 2024

我没有看懂,哪个名字写错了?

from jetcache.

xiongmaodeguxiang avatar xiongmaodeguxiang commented on June 19, 2024

我理解advisor.setAdviceBeanName()这个方法中设置的应该是advice的name吧,就是JetCacheInterceptor这个bean的名字

from jetcache.

xiongmaodeguxiang avatar xiongmaodeguxiang commented on June 19, 2024

当然,您已经执行了advisor.setAdvice(jetCacheInterceptor),所以advice已经不为空了,所谓我理解您再指定adviceBeanName也没有意义了

from jetcache.

areyouok avatar areyouok commented on June 19, 2024

这代码好多年了我也不太记得,但我的理解是需要指定一个非默认的名字,否则如果有多个advisor呢?

或者你的意思是advisor.setAdviceBeanName(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME);这一行是多余的?

from jetcache.

xiongmaodeguxiang avatar xiongmaodeguxiang commented on June 19, 2024

哈哈,大佬,我也是最近在研读学习您的代码,梳理一下逻辑,对您很是敬佩。

  1. 如果多个advisor,某个method是否命中在pointCut中已经判断过滤了,所以存在多个advisor也没有问题,而且每个advisor如果没有指定,Spring会给他们自动生成一个bean名称

2.是的,advisor.setAdviceBeanName(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME);这一行就多余了
因为您的代码中执行了advisor.setAdvice(jetCacheInterceptor);
具体的逻辑在org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor#getAdvice方法中,
逻辑大概是如果你设置了advice了那么就直接返回advice,如果没有设置,那么它会从spring中获取您指定的adviceBeanName的bean作为advice

不过是个小问题而已,不太影响什么

from jetcache.

areyouok avatar areyouok commented on June 19, 2024

那可以把这一行删掉试试单元测试是否还能跑通

from jetcache.

xiongmaodeguxiang avatar xiongmaodeguxiang commented on June 19, 2024

我把这一行删除后,项目是可以正常跑通的

from jetcache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.