java - Dagger 2 not generateing components on Eclipse -
i have created java application eclipse , i'm using maven package management. several days ago able configure application work dagger 1 (adding dependencies pom file, enabling annotation processing , adding dagger, dagger-compile, javax , javawriter jars factory path). after several discussion colleagues decided use dagger 2. tried migrate dagger 1 implementation dagger 2 following dagger 2 documentation, did not work.
for unexplained reason @component
class dagger
prefix not generated.
because of decided try dagger 2 coffee sample.
i created new eclipse java project, converted maven, added sample code , dagger 2 dependencies pom file:
<dependency> <groupid>com.google.dagger</groupid> <artifactid>dagger</artifactid> <version>2.0.1</version> </dependency> <dependency> <groupid>com.google.dagger</groupid> <artifactid>dagger-compiler</artifactid> <version>2.0.1</version> <optional>true</optional> </dependency>
my build failed following error:
exception in thread "main" java.lang.error: unresolved compilation problem: daggercoffeeapp_coffee cannot resolved
i extracted coffee
component interface separate file (named coffee.java
) , tried again got same error.
i removed factory path jars dagger 1, result still same. if try add dagger 2 jars, multiple problems have occurred window following error text errors occurred during build. errors running builder 'java builder' on project 'dagger'. com/google/common/collect/setmultimap
i found out problem occurs when add dagger-compiler
jar.
if remove every jar factory path build still fails.
i tried find daggercoffee
file, should automatically generated couldn't find it.
how can use dagger 2 eclipse? red documentation several times , spend day researching this, no luck far.
it works using m2e-apt. no need add custom libs:
- install m2e-apt
- window -> preferences -> maven -> annotation processing: select "automatically configure jdt apt"
- update maven project
Comments
Post a Comment