无法找到导入javax.inject.Inject包 [英] Can't locate import javax.inject.Inject package
问题描述
我正在尝试将Dagger实现为IntelliJ项目中的依赖注入器,但我的代码失败了:
I'm trying to implement Dagger as a dependency injector in an IntelliJ project, but my code is failing on:
import javax.inject.Inject;
Intellij正在寻找' javax
'包,但不是'注入
'包,所以它失败了。
Intellij is finding the 'javax
' package, but not the 'inject
' package, so it fails.
我是Android新手,所以我道歉如果这是一个没脑子,但任何人都可以告诉我为什么没有找到注入包吗?
I am new to Android, so I apologize if this is a no brainer, but can anyone tell me why the inject package is not being found?
推荐答案
Dagger依赖于JSR 330,用于依赖注入的Java标准注释(想想: @Inject
, @Singleton
等) 。
Dagger depends on JSR 330, the Java standard annotations which are used for dependency injection (think: @Inject
, @Singleton
, etc.).
这是一个你必须包含的独立jar。如果您使用的是具有集成依赖关系管理的构建系统(Maven,Gradle,Ant + Ivy,sbt),那么您可以免费获得。如果您仍在复制罐子,那么您必须手动添加它。
This is a separate jar that you have to include. If you were using a build system with integrated dependency management (Maven, Gradle, Ant+Ivy, sbt) you'd get this for free. If you're still copying around jars then you have to add it manually.
您可以从 Maven central (位于底部)。
You can download the latest jar from Maven central (at the bottom).
这篇关于无法找到导入javax.inject.Inject包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!