Hello, I'm trying to get Mapstruct working with gradle. The implementations generate and work great when I run the service from the boot dashboard in eclipse, but they don't generate when run with gradlew bootrun, and the bean can't be found. Here is the error:
Field fooMapper in ServiceImpl required a bean of type 'FooMapper' that could not be found.
Consider defining a bean of type 'FooMapper' in your configuration.
and here is my build.gradle file
plugins {
id "org.springframework.boot"
id "groovy"
id "com.diffplug.eclipse.apt" version "3.31.0"
}
configurations {
// configuration to enable running bootRun locally
// with embedded h2 database
runlocal
}
ext {
mapstructVersion = "1.5.0.Beta1"
}
dependencies {
implementation "org.mapstruct:mapstruct:${mapstructVersion}"
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}"
testImplementation "org.testng:testng:6.10", "org.easytesting:fest-assert:1.4"
implementation project(":cpms-common")
implementation "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
implementation "org.springframework.boot:spring-boot-starter-jdbc:$springBootVersion"
implementation "org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion"
implementation "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
implementation "org.springframework.boot:spring-boot-starter-validation:$springBootVersion"
implementation "org.codehaus.gpars:gpars:1.2.1"
developmentOnly "org.springframework.boot:spring-boot-devtools:$springBootVersion"
runlocal project(":test-db")
testImplementation project(":test-db")
}
sourceSets.main.groovy.srcDirs += ["build/generated/sources"]
bootRun {
classpath = sourceSets.main.runtimeClasspath + configurations.runlocal
}
tasks.withType(JavaCompile) {
options.compilerArgs = [
"-Amapstruct.suppressGeneratorTimestamp=true",
"-Amapstruct.defaultComponentModel=spring",
"-Amapstruct.verbose=true"
]
}
is it because my code is written in groovy? But then why would it work with the boot dashboard in eclipse? Any help would be really appreciated!