简体   繁体   English

Intellij 不选择 mapstruct 生成的类

[英]Intellij is not picking mapstruct generated classes

I am trying to fix an issue with Intellij and Mapstruct.我正在尝试解决 Intellij 和 Mapstruct 的问题。

Earlier I have used Java 8 and Gradle 4.6 and Mapstruct was working fine.早些时候我使用过 Java 8 和 Gradle 4.6,Mapstruct 运行良好。 Now I have upgraded Java to 11 and Gradle to 4.10.3.现在我已将 Java 升级到 11,将 Gradle 升级到 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.现在的问题是,在构建之后,当我运行应用程序时,我最终得到了 UnSatisfiedDependencyException,因为某些 Mapper 类不可用。 I have gone through many questions in SO, most of them suggested to delegate the Intellij build/run operation to Gradle.我在 SO 中遇到了很多问题,其中大多数问题都建议将 Intellij 构建/运行操作委托给 Gradle。 But I want Intellij to run the application and tests.但我希望 Intellij 运行应用程序和测试。 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:这是我的 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.以前,映射器类是在 src-->generated 中生成的。 Now after the upgrade, the mapper classes not generated in src->generated.现在升级后,src->generated 中没有生成映射器类。 Gradle generated classes are present in root-->build where I am able to see the mapper classes. Gradle 生成的类存在于 root-->build 中,我可以在其中看到映射器类。 Intellij is not picking the generated classes correctly or I am missing some config. Intellij 没有正确选择生成的类,或者我缺少一些配置。

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. PS:我使用的是 Intellij 2019.1.2、Mapstruct 1.2.0.Final 和 Spring Boot 2.2.2.RELEASE。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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