我有Eclipse Luna和标准的GWT Web应用程序项目。我尝试启用注释处理以使Dagger2正常工作。以下是我的项目特定配置:
在我点击之后,Eclipse向我显示以下错误:
如何解决此错误?
修改:我创建了一个演示项目来演示问题:https://github.com/confile/GWT-Dagger2-Demo
我查看了dagger2编译器的pom.xml并添加了更多依赖项但仍没有进展。这是我做的:
编辑:我尝试使用带有here依赖关系的dagger2编译器jar:
当我进行GWT编译时,我收到以下错误:
Compiling module test.GWTT
Tracing compile failure path for type 'test.client.test2.Dagger_MyWidgetGinjector'
[ERROR] Errors in 'file:/Users/mg/Documents/Eclipse/Eclipse-4.4/GWTT/.apt_generated/test/client/test2/Dagger_MyWidgetGinjector.java'
[ERROR] Line 9: No source code is available for type javax.inject.Provider<T>; did you forget to inherit a required module?
Tracing compile failure path for type 'test.client.test2.MyWidgetClientModule$$ProvideSomeServiceFactory'
[ERROR] Errors in 'file:/Users/mg/Documents/Eclipse/Eclipse-4.4/GWTT/.apt_generated/test/client/test2/MyWidgetClientModule$$ProvideSomeServiceFactory.java'
[ERROR] Line 7: No source code is available for type dagger.Factory<T>; did you forget to inherit a required module?
[ERROR] Aborting compile due to errors in some input files
我的Java构建路径上有以下库:
编辑Gradle:我还尝试在eclipse中使用gradle激活注释处理。这是我的gradle build.gradle文件:
apply plugin: 'apt'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'gwt'
apply plugin: 'jetty'
sourceCompatibility = 1.7
version = '1.0'
eclipse {
classpath {
downloadSources=true
downloadJavadoc=true
}
}
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.jimdo.gradle:gradle-apt-plugin:0.5-SNAPSHOT'
}
}
repositories {
mavenCentral()
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT:jar-with-dependencies'
compile 'com.google.guava:guava:18.0'
compile 'com.google.guava:guava-gwt:18.0'
compile 'javax.inject:javax.inject:1'
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
}
gwt {
gwtVersion='2.7.0'
logLevel = 'INFO'
minHeapSize = "512M";
maxHeapSize = "1024M";
compiler {
strict = true;
}
modules 'test.GWTT'
}
tasks.withType(de.richsource.gradle.plugins.gwt.AbstractGwtActionTask) {
args '-XjsInteropMode', 'JS'
}
在'gradle build``之后得到:
/Users/mg/Documents/Grails/GGTS3.6.2/TestGradle2/src/main/java/test/client/GWTT.java:16: error: cannot find symbol
MyWidgetGinjector injector = Dagger_MyWidgetGinjector.create();
^
symbol: variable Dagger_MyWidgetGinjector
我可以看到Dagger_MyWidgetGinjector.java
中已创建build/source/apt/test/client/test2/
。我仍然需要弄清楚如何添加新生成的源,以便eclipse可以使用刷新依赖项找到它?
答案 0 :(得分:1)
Dagger 2并没有遮蔽它的依赖关系(所以)所以你必须将所有的dagger-compiler依赖关系添加到工厂路径。
编辑那里包含所有依赖项的sa jar-with-dependencies
风格,让像您这样的用户更轻松地使用所谓的托管依赖关系< / em>,以使用具有相同传递依赖性的其他注释处理器时可能存在冲突为代价。理想情况下,dagger-compiler应遮蔽其依赖关系以生成无冲突的uber-jar;我最终会相信。