【问题标题】:Mapstruct: aftermapping with parametersmapstruct:带参数的aftermapping
【发布时间】:2022-11-19 13:43:45
【问题描述】:

这是我的代码:

    @Mapping(target = "auditoriaMetas", qualifiedByName = "sdf")
    public abstract Auditoria mapToModificacio(QdCF qdcf, QdCFPresenter qdcfPresenter, Integer idInstrument);

    @Named("sdf")
    public List<AuditoriaMeta> mapToMetas(QdCF current, @Context QdCFPresenter incomming) {
        return null;
    }

我希望在执行mapToModificatio 之后,mapToMetas 也被执行。

上面的代码不执行。

有任何想法吗?

【问题讨论】:

    标签: mapstruct


    【解决方案1】:

    Mapstruct 不会考虑将普通值放入带有 @Context 注释的值中。因此,如果您用 @Context 标记某些内容,那么它应该在整个调用链中都被标记为那样。

    例如:

        @Mapping(target = "auditoriaMetas", qualifiedByName = "sdf")
        public abstract Auditoria mapToModificacio(QdCF qdcf, @Context QdCFPresenter qdcfPresenter, Integer idInstrument);
    
        @Named("sdf")
        public List<AuditoriaMeta> mapToMetas(QdCF current, @Context QdCFPresenter incomming) {
            return null;
        }
    

    【讨论】:

      猜你喜欢
      • 2019-05-10
      • 1970-01-01
      • 2016-07-23
      • 2020-06-05
      • 2018-05-21
      • 2022-08-19
      • 1970-01-01
      • 2021-11-21
      • 2022-10-15
      相关资源
      最近更新 更多