Dagger 2 Component does not generate Dagger Prefix Classes for building

I am new to Dagger 2, and I tried the example of a coffee dagger in IntelliJ, and it seems that this does not create DaggerCoffeeApp_Coffee (it should generate it), although I followed the code example for Dagger 2 on github.

Public class CoffeeApp {
    @Singleton
    @Component(modules = {DripCoffeeModule.class})
    public interface Coffee {

        CoffeeMaker maker();
    }
    public static void main(String args[]){


        Coffee coffee = DaggerCoffeeApp_Coffee.builder().build();
    }
}

Here is my pom.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.tim.test</groupId>
    <artifactId>Dagger2Experiment</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <slf4j-api.version>1.7.12</slf4j-api.version>
    </properties>
    <repositories>
        <repository>
            <id>sonatype</id>
            <name>sonatype-repo</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        </repository>
    </repositories>
    <dependencies>

        <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>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j-api.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j-api.version}</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

</project>

I tried a different solution from the topic below, but nothing works:

I also added the jar file to my buildpath dagger-2.0.1.jar for the application at run time and dagger-compiler-2.0.1.jar in your assembly at compile time.

Update I used DaggerCoffeeApp_Coffee.builder (). Build () in the code snippet above, since I edited my code to follow the code example in the Dagger 2 github below, after I could not find the constructor. Link below:

https://github.com/google/dagger/blob/master/examples/simple/src/main/java/coffee/CoffeeApp.java

.

+4
1

, , . , , pom.xml .

  • , DripCoffeeModule , . .

    @Module
    
    public DripCoffeeModule {
    
    //Uses default constructor
    
    }
    
  • , , , - . ( CoffeeApp.) , , .

    DaggerCoffeeApp_Coffee.builder().build();
    

, . :

, Dagger.

, :

DaggerCoffee.builder().build();

:

DaggerCoffee.create();

1, :

DaggerCoffee.builder().dripCoffeeModule(new DripCoffeeModule()).build();

. Dagger 2.

Maven pom.xml - :

:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <dependencies>
                <dependency>
                    <groupId>com.google.dagger</groupId>
                    <artifactId>dagger-compiler</artifactId>
                    <version>2.0</version>
                    <optional>true</optional>
                </dependency>
            </dependencies>
        </plugin>
+1

Source: https://habr.com/ru/post/1610512/