mapstruct / mapstruct/mapstruct
Error “constructor ... in class ... cannot be applied to given types” while mapping with enum in the constructor
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 7.7k
- 派生
- 1.1k
- PR 合并指标
- 30 天内没有已合并 PR
描述
Hello, I have an issue with MapStruct when converting entity class into the DTO. This issue occur only when I have enum in the DTO's constructor.
Here is my DTO class
class ResourceDto(
val id: Long,
val name: String,
val status: ResourceStatus,
val location: LocationDto,
)
and error that I am getting while building
constructor ResourceDto in class ResourceDto cannot be applied to given types; ResourceDto resourceDto = new ResourceDto(); ^ required: long,String,ResourceStatus,LocationDto found: no arguments reason: actual and formal argument lists differ in length
When I remove the enum ResourceStatus from the constructor, it works as expected. Do you have any suggestion, why is this happening?
I am using mapstruct version 1.4.2.Final and Kotlin 1.5.10 with Spring Boot
Thanks a lot!
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Kotlin ResourceDto 构造函数和编译器报告的生成 Java mapper 开始,使用 MapStruct 1.4.2.Final 和 Kotlin 1.5.10。分别在有和没有 ResourceStatus 的情况下复现映射,然后检查生成的构造函数调用。完成标准是确定该 enum 情况属于 MapStruct 缺陷还是 Kotlin 互操作缺陷,并记录已确认的结果。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java, kotlin
- 领域
- backend-api-design
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 28/100