#StackBounty: #java #mongodb #spring-boot #gradle #querydsl How to add querydsl-mongodb to Spring Boot Gradle 5.6.1 project

Bounty: 50

I am trying to create dynamic query to a mongo database from spring boot gradle project.
My gradle version: 5.6.1

Here is my build.gradle file:

plugins {
    id 'org.springframework.boot' version '2.2.2.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'java'
}

group = 'com.onssoftware'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

dependencies {

    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'

    // https://mvnrepository.com/artifact/com.querydsl/querydsl-mongodb
    compile group: 'com.querydsl', name: 'querydsl-mongodb', version: '4.2.2'

    // https://mvnrepository.com/artifact/com.querydsl/querydsl-apt
    compile group: 'com.querydsl', name: 'querydsl-apt', version: '4.2.2'
    //annotationProcessor group: 'com.querydsl', name: 'querydsl-apt', version: '4.2.2'

    annotationProcessor "com.querydsl:querydsl-apt:4.2.2"
    //annotationProcessor("org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor")

    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

test {
    useJUnitPlatform()
}

My application.properties file:


spring.data.mongodb.username = user
spring.data.mongodb.password = pass
spring.data.mongodb.host = 172.17.0.2
spring.data.mongodb.port = 27017
spring.data.mongodb.database = test_db

Problem is: Q classes are not generating for my Documents.
Any suggestion welcome. Thanks.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.