Coder Social home page Coder Social logo

Comments (3)

liufeiyu1002 avatar liufeiyu1002 commented on June 22, 2024 1

首先说为啥会扫描2次, 他是由不同的俩个 ServiceAnnotationPostProcessor 类实例扫描的
第一个ServiceAnnotationPostProcessor 实例创建的时机是 通过 enabledubbo 注解注入的 从 DubboComponentScanRegistrar 类中,
第二个实例是 springboot autoconfig 的spring.factories 文件扫描注入的 当配置了 属性 dubbo.scan.base-packages 以后会注入一个 ServiceAnnotationPostProcessor 新的实例对象 (查看 DubboAutoConfiguration )

为啥第二次会扫描不到 因为 用了容器中的 servicePackagesHolder 来校验了 扫描路径是否被扫描过 以及类是否已经被扫描过,如果被扫描过是不会再次被扫描的 所以你的第二次进入是一个空的返回,
你第一次的扫描路径是 org.dromara.system(EnableDubbo 的scanBasePackages 属性) 第二个为 org.dromara.**.dubbo (properties中 dubbo.scan.base-packages) 第二个路径的所有类都在第一个路径中扫描过时 第二个路径就不会扫描返回到任何类

from dubbo.

AlbumenJ avatar AlbumenJ commented on June 22, 2024

Please translate the content to English:)

from dubbo.

JavaLionLi avatar JavaLionLi commented on June 22, 2024

首先说为啥会扫描2次, 他是由不同的俩个 ServiceAnnotationPostProcessor 类实例扫描的 第一个ServiceAnnotationPostProcessor 实例创建的时机是 通过 enabledubbo 注解注入的 从 DubboComponentScanRegistrar 类中, 第二个实例是 springboot autoconfig 的spring.factories 文件扫描注入的 当配置了 属性 dubbo.scan.base-packages 以后会注入一个 ServiceAnnotationPostProcessor 新的实例对象 (查看 DubboAutoConfiguration )

为啥第二次会扫描不到 因为 用了容器中的 servicePackagesHolder 来校验了 扫描路径是否被扫描过 以及类是否已经被扫描过,如果被扫描过是不会再次被扫描的 所以你的第二次进入是一个空的返回, 你第一次的扫描路径是 org.dromara.system(EnableDubbo 的scanBasePackages 属性) 第二个为 org.dromara.**.dubbo (properties中 dubbo.scan.base-packages) 第二个路径的所有类都在第一个路径中扫描过时 第二个路径就不会扫描返回到任何类

那是否配了 dubbo.scan.base-packages 就不需要 EnableDubbo 注解了, 或者EnableDubbo 标注后 就不需要 dubbo.scan.base-packages 配置了

from dubbo.

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.