'No class def found error when building maven project

I am using querydsl and when I am trying to build maven project it fails:

Caused by: java.lang.ClassNotFoundException: com.mysema.codegen.model.Type

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


Solution 1:[1]

You can try adding below dependencies into your maven pom.xml:

<!-- https://mvnrepository.com/artifact/com.mysema.codegen/codegen -->
<dependency>
    <groupId>com.mysema.codegen</groupId>
    <artifactId>codegen</artifactId>
    <version>0.6.8</version>
</dependency>

Then compile the project again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SeanH