简体   繁体   中英

Intellij is not picking mapstruct generated classes

I am trying to fix an issue with Intellij and Mapstruct.

Earlier I have used Java 8 and Gradle 4.6 and Mapstruct was working fine. Now I have upgraded Java to 11 and Gradle to 4.10.3. Now the problem is, after the build, when I run the application, I ended up with UnSatisfiedDependencyException because some Mapper class was not available. I have gone through many questions in SO, most of them suggested to delegate the Intellij build/run operation to Gradle. But I want Intellij to run the application and tests. This post is suggesting the solution I want but after applying this, I am getting some different compile error.

This is a section from my build.gradle:

//mapstruct lib to generate mappings between Java bean types
compileOnly("org.mapstruct:mapstruct-processor:${mapStructVersion}")
annotationProcessor("org.mapstruct:mapstruct-processor:${mapStructVersion}")

//lib to support lombok
compileOnly 'org.projectlombok:lombok:1.18.6'
annotationProcessor 'org.projectlombok:lombok:1.18.6'

Previously, the mapper classes was generated in src-->generated. Now after the upgrade, the mapper classes not generated in src->generated. Gradle generated classes are present in root-->build where I am able to see the mapper classes. Intellij is not picking the generated classes correctly or I am missing some config.

Please help me to fix the path correctly.

PS: I am using Intellij 2019.1.2 , Mapstruct 1.2.0.Final and Spring Boot 2.2.2.RELEASE.

尝试使用implementation而不是compileOnly因为它在官方 MapStruct 示例中: https : //github.com/mapstruct/mapstruct-examples/blob/master/mapstruct-on-gradle/build.gradle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM