等效于匕首@COMPONENTSCAN?

发布于 2025-01-29 07:13:05 字数 153 浏览 5 评论 0原文

抱歉,我要问的这个基本问题,但是有人可以告诉我匕首依赖注入是否可以与@module,@provides @inject等一起使用,而不用使用@component注释?

在春季DI中,我们使用@ComponentScan让Spring知道在哪里可以找到豆。匕首在匕首中等同于什么?

Sorry for this basic question I am asking but can someone tell me if dagger dependency injection can work just with @module, @provides @Inject etc. That is without using @component annotation?

In spring DI, we use @componentScan to let spring know where to find beans. What is the equivalent of this in dagger?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寒尘 2025-02-05 07:13:05

您始终需要@component。这是“外部”依赖关系的切入点。

当我说“外部”时,我的意思是在创建组件内的依赖关系图之后,现在是时候注入某些活动的时候了。因此,组件暴露了“外部”的依赖关系。

同时,组件可以与其他子组件共享其依赖关系。

组件取决于模块来知道如何创建依赖项。

You always need @Component. This is the entry point for dependencies from "outside".

When I say "outside" I mean the case where after the dependency graph inside the Component is created and now it is a time for some Activity to be Injected for example. So the component exposed dependencies for the "outside".

At the same time, a component can share its dependencies with other Subcomponents for example.

The Components depend on the Modules to know how to create dependencies.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文