简体   繁体   English

将匕首与 java 11 和 maven 一起使用

[英]Using Dagger with java 11 and maven

Does Google Dagger DIF works with java 11? Google Dagger DIF 是否适用于 java 11?

If not, what is the alternative, given that changing the project to use java 8 is not possible.如果不是,那么有什么替代方法,因为不可能将项目更改为使用 java 8。

Yes, it is possible to use dagger 2.32 with maven and java 11.是的,可以将 dagger 2.32 与 maven 和 java 11 一起使用。

I was having issues with compilation process and eclipse environment.我在编译过程和 eclipse 环境方面遇到问题。

Eclipse was showing errors saying that DaggerMyClassComponent was not found. Eclipse 显示错误,提示找不到 DaggerMyClassComponent。 DaggerMyClassComponent is a generated class from MyClassComponent with @Component annotation from Dagger. DaggerMyClassComponent 是从 MyClassComponent 生成的 class 并带有来自 Dagger 的 @Component 注释。 This class (and others) is generated when we do 'mvn clean compile' command.这个 class(和其他)是在我们执行“mvn clean compile”命令时生成的。 Before that, eclipse will show errors.在此之前,eclipse 会显示错误。

Also, if you run 'Maven -> Update Project', eclipse will fix the problem (it will run compile phase from maven).此外,如果您运行“Maven -> 更新项目”,eclipse 将解决问题(它将从 maven 运行编译阶段)。 You can check generated classes in /target/generated-sources/annotation folder.您可以在 /target/generated-sources/annotation 文件夹中检查生成的类。

Also, while developing with dagger and eclipse, errors may appear if you change classes annotated with @Components and @Modules.此外,在使用 dagger 和 eclipse 进行开发时,如果更改使用 @Components 和 @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).运行 'mvn clean' 解决了与从 Dagger 生成的类相关的错误,因为此命令会擦除 /target 文件夹内容(包括从 dagger 生成的旧类)。

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

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