在Java 11和Maven中使用Dagger [英] Using Dagger with java 11 and maven
问题描述
Google Dagger DIF是否可以与Java 11一起使用?
Does Google Dagger DIF works with java 11?
如果没有,那么考虑将项目更改为使用Java 8是不可能的.
If not, what is the alternative, given that changing the project to use java 8 is not possible.
推荐答案
是的,可以在Maven和Java 11中使用dagger 2.32.
Yes, it is possible to use dagger 2.32 with maven and java 11.
我在编译过程和日食环境方面遇到问题.
I was having issues with compilation process and eclipse environment.
Eclipse显示错误,提示未找到DaggerMyClassComponent.DaggerMyClassComponent是MyClassComponent生成的类,带有Dagger的@Component注释.当我们执行"mvn clean compile"命令时,将生成此类(和其他类).在此之前,eclipse将显示错误.
Eclipse was showing errors saying that DaggerMyClassComponent was not found. DaggerMyClassComponent is a generated class from MyClassComponent with @Component annotation from Dagger. This class (and others) is generated when we do 'mvn clean compile' command. Before that, eclipse will show errors.
此外,如果您运行'Maven->更新项目",eclipse将解决问题(它将从maven运行编译阶段).您可以在/target/generate-sources/annotation文件夹中检查生成的类.
Also, if you run 'Maven -> Update Project', eclipse will fix the problem (it will run compile phase from maven). You can check generated classes in /target/generated-sources/annotation folder.
此外,在使用匕首和月食进行开发时,如果更改用@Components和@Modules注释的类,则可能会出现错误.运行"mvn clean"可以解决与Dagger生成的类有关的错误,因为此命令会删除/target文件夹内容(包括从Dagger生成的旧类).
Also, while developing with dagger and eclipse, errors may appear if you change classes annotated with @Components and @Modules. Running 'mvn clean' solves the errors related with generated classes from Dagger, because this command erases the /target folder content (including old generated classes from dagger).
这篇关于在Java 11和Maven中使用Dagger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!