i heard Dagger 2 from a friend use it in Android. it pretty good!
But i have a crazy idea, i want to try Dagger 2 example in a pure java project build in Maven and use intellij IDEA. But something wrong by Compiler couldn't generate DaggerCoffeeShop class from ConffeeShop Interface like Dagger user guide.
All my example code same as example.
CoffeeShop coffeeShop = DaggerCoffeeShop.builder()
.dripCoffeeModule(new DripCoffeeModule())
.build();
I tried with turn on enable annotation processing
in setting
> compiler
but it not work. I need your help to complete my crazy idea. :(
Run testsOpen the Maven tool window. Under the Lifecycle node select test. Note that goals specified in the Maven surefire plugin will be activated at this phase and all tests in a project or in a module will be run.
In the Project tool window, right-click your project and select Add Framework Support. In the dialog that opens, select Maven from the options on the left and click OK. IntelliJ IDEA adds a default POM to the project and generates the standard Maven layout in Project tool window.
Use JDK 8. It should support JDK 9, but I did not figure it out how to do it ;)
Be sure to include in POM:
<dependencies>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger</artifactId>
<version>2.11</version>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.11</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.11</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With