最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Does a mapper of MapStruct really use a class constructor? - Stack Overflow

programmeradmin3浏览0评论

Let's say I need to map class Source to class Destination with an interface of the mapstruct.

@Mapper
public interface MyMapper {

   @Mapping(target = "attribute1", source = "attribute1")
   Destination toDestination(Source source);
}

If class Destination has two constructors, a compile error will occur:

"Ambiguous constructors found for creating Destination ..."

If the attribute1 of the Destination class doesn't have its setter, another compile error will occur:

"Unknown property"

So, how exactly does the mapper map class attributes?

发布评论

评论列表(0)

  1. 暂无评论