Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QueryDsl classes are not generated in IntelliJ

I have the following class and I would like to try out querydsl and make some basic queries. Using intelliJ 2017.3, no class QUser is generated. I've tried googling my problem and each SO answer seems to offer a different solution (some didn't work and some I did not understand cause I've never used this things before) and most tutorials seem to do completely different stuff.

I have tried making queries using whatever Spring Boot seems to have built-in (no idea, simply seems to work, but it's too basic from the looks of it) and the queries work just fine so I'm guessing it's some configuration issue (I'm a maven and spring noob).

// User.java
@Entity
@Table(name = "symptoms")
public class Symptom
{
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @NotNull
    private String name;

    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }
}

I have added these things to the pom.xml:

    <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <version>4.1.4</version>
    </dependency>

    <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-jpa</artifactId>
        <version>4.1.4</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.25</version>
    </dependency>



    <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>apt-maven-plugin</artifactId>
            <version>1.1.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
        </plugin>
like image 287
Xzenon Avatar asked Dec 24 '17 00:12

Xzenon


1 Answers

You can fix the problem by: Open target folder --> Right click to generated-sources folder -> Mark Directory As -> Generated sources root.

After correctly marking the generated sources folder it worked without any problems for me. If IntelliJ doesn't instantly recognize the marked folder and the error still persists, mvn clean install usually helps.

like image 148
John Avatar answered Nov 12 '22 06:11

John