简体   繁体   English

无法使用Dagger 2建立图表

[英]Cannot build graph with Dagger 2

I am trying to create the dependency graph with Dagger 2 based on the example of the dagger 2 website (the coffeeMaker and the source is here : https://github.com/google/dagger/tree/master/examples/simple ). 我正在尝试基于Dagger 2网站的示例(Dream 2网站的示例)来创建Dagger 2的依赖关系图(coffeeMaker,其来源位于: https : //github.com/google/dagger/tree/master/examples/simple )。

I created the component as stated in the site : 我创建了网站中所述的组件:

@Component(modules = {DripCoffeeModule.class})
public interface CoffeeShop {
    CoffeeMaker maker();
}

The annotation processor correctly generates the files (in the target directory) but I am unable to find the DaggerCoffeeShop class. 注释处理器正确生成了文件(在目标目录中),但是我找不到DaggerCoffeeShop类。 (Ctrl + space) does not work. (Ctrl +空格)不起作用。

How can I solve this problem? 我怎么解决这个问题?

Those generated files are usually placed in the target folder of your project (fe: myProject/target/generated-sources/annotations/my/package/DaggerCoffeeShop.java ). 这些生成的文件通常放置在项目的目标文件夹中(例如: myProject/target/generated-sources/annotations/my/package/DaggerCoffeeShop.java )。 So you just have to indicate to your IDE that the annotations folder is a source folder. 因此,您只需要向IDE指示annotations文件夹是源文件夹。

  • Intellij 的IntelliJ
  • Eclipse: Project > Properties > Java Build Path > Source > Add Folder Eclipse: Project > Properties > Java Build Path > Source > Add Folder

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM