Using QueryDSL with MongoDB - java.lang.NoClassDefFoundError

As indicated in the GA release announcement and release train wiki, Spring Data Hopper upgrades to Querydsl 4. Thus, you also need to upgrade your application to it.


I had the same problem with QueryDsl / Spring Boot 2.1.3.

Simply changed: From:

<dependency>
    <groupId>com.mysema.querydsl</groupId>
    <artifactId>querydsl-mongodb</artifactId>
    <version>3.6.6</version>
</dependency>
<dependency>
    <groupId>com.mysema.querydsl</groupId>
    <artifactId>querydsl-apt</artifactId>
    <version>3.6.6</version>
</dependency>

To:

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

And relevant imports and it worked.