I created a Java application with Eclipse and I use Maven to manage packages. A few days ago, I was able to configure my application to work with Dagger 1 (add dependencies to the pom file, enable annotation processing and add daggers, daggers, javax and javawriter jars to the Factory path). After several discussions with my colleagues, we decided to use Dagger 2. I tried to migrate the implementation of Dagger 1 to Dagger 2 by following the Dagger 2 documentation , but that did not work.
For some inexplicable reason, the @Component class with the Dagger prefix is not generated.
Because of this, I decided to try a sample of the dagger 2 coffee .
I created a new Java Eclipse project, converted it to Maven, added sample code and Dagger 2 dependencies to the 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:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: DaggerCoffeeApp_Coffee cannot be resolved
I extracted the Coffee component interface into a separate file (named Coffee.java ) and tried again, but got the same error.
I removed the Factory Path of Dagger 1 containers, but the result is still the same. If I try to add Dagger 2 banks, I get a window Several problems with the following error text Errors occurred during the build. Errors running builder 'Java Builder' on project 'dagger'. com/google/common/collect/SetMultimap Errors occurred during the build. Errors running builder 'Java Builder' on project 'dagger'. com/google/common/collect/SetMultimap
I found out that the problem occurs when I add a jar of dagger-compiler .
If I remove each jar from the Factory Path, the assembly still fails.
I tried to find the DaggerCoffee file, which should be automatically generated, but I could not find it.
How to use Dagger 2 with Eclipse? I dye the documentation several times and spent the day researching this, but so far no luck.