【问题标题】:Intellij doesn't see the generated class by MapStructIntellij 看不到 MapStruct 生成的类
【发布时间】:2018-11-25 11:46:00
【问题描述】:

当我在spring-boot 中使用MapStruct 时,它会生成一个impl class,我想访问该文件以在单元测试中导入,但intellij 看不到它

@SpringBootTest(classes={OrderMapperImpl.class})

我得到了错误

Can't find a symbol OrderMapperImpl

【问题讨论】:

  • 你检查this相关问题了吗。
  • 是的,它不起作用,因为 intellij 无法识别 OrderMapperImpl,因为它是生成的类
  • 将生成的类文件夹添加到项目源中。
  • 我该怎么做?
  • pom 声明的外观如何以及您使用的是哪个 IntelliJ 版本?

标签: java spring-boot spring-boot-test mapstruct


【解决方案1】:

您可以通过右键单击目录target/generated-sources/annotations > Mark directory as... > Generated Sources Root 来告诉 IntelliJ 将 mapstructs 生成的类作为源文件。

如果您配置了另一个输出路径,则需要选择它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-29
    • 2017-12-21
    • 1970-01-01
    • 2017-09-21
    • 2021-03-06
    • 2021-03-20
    • 2018-09-11
    • 1970-01-01
    相关资源
    最近更新 更多