0.背景

使用mapstruct时出现:

Unknown property "xxx" in result type xxx. Did you mean "null"?

同时,项目中也用到了lombok。

mapstruct版本: 1.4.1.Final

lombok版本: 1.8.22 (继承的Spring2.5.6)

<!-- mapstruct START--> <dependency> <groupId>org.mapstruct</groupId> <artifactId>mapstruct</artifactId> <version>${mapstruct.version}</version> <!--这个scope 只能作用在编译和测试时,同时没有传递性。--> <scope>provided</scope> </dependency> <dependency> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>${mapstruct.version}</version> <scope>provided</scope> </dependency> <!-- mapstruct END --> <!-- lombok --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <scope>provided</scope> </dependency>

1.解决

1.1 方案1:调整顺序

代码生成器annotationProcessor标签部分,将lombok放在mapstruct之前

<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> <!--自动生成代码annotationProcessor--> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> </path> <path> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>${mapstruct.version}</version> </path> </annotationProcessorPaths> </configuration> </plugin> </plugins> </build>

1.2 方案2:官网叽叽歪歪一堆

官网说Lombok 1.18.16或更高版本要添加lombok-mapstruct-binding的依赖,但是经过方案1我的问题它就解决了

原文在这里:https://mapstruct.org/faq/

其实文中也提到了先在模块1使用lombok再在模块2使用mapstruct。

        <!-- mapStruct-lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
<scope>provided</scope>
</dependency>

Mapstruct使用时报Unknown property xxx in result type xxx. Did you mean null的更多相关文章

  1. Access restriction: The method XXX from the type XXX is not accessible due to restriction XXX

    插件重构的时候 遇到这个问题 Access restriction: The method setDefaultAutoCommit(boolean) from the type BasicDataS ...

  2. [Android]编译错误:Could not get unknown property 'release' for SigningConfig container

    使用Gradle进行安卓编译时,出现如下错误: Could not get unknown property 'release' for SigningConfig container. 原因: 在主 ...

  3. 在使用Ibatis查询数据返回时,报如下错误:java ibatis The error happened while setting a property on the result object

    问题: 在使用Ibatis查询数据返回时,报如下错误: [com.show.add.proxy.SqlMapClientTemplateProxy]com.ibatis.common.jdbc.exc ...

  4. - configuration.module has an unknown property 'loader' 问题解决

    错误提示: Invalid configuration object. Webpack has been initialised using a configuration object that d ...

  5. Java+selenium chrome 常见的问题WebDriverException: unknown error: call function result missing 'value'

    运行chrome浏览器 报错:"main" org.openqa.selenium.WebDriverException: unknown error: call function ...

  6. 两招解决异常_Cannot find any information on property 'XXX' in a bean of type 'XXX'的问题

    第一招 在进行Java Web项目开发的时候,我碰到过下面这个异常: Cannot find any information on property 'XXX' in a bean of type ' ...

  7. Python3 Selenium自动化测试赋值出现:WebDriverException: Message: unknown error: call function result missing 'value'

    Python3 Selenium自动化测试赋值出现:WebDriverException: Message: unknown error: call function result missing ' ...

  8. Struts2报错:No result defined for action xxx and result input

    case如下: 1. 后台程序要升级, 修改了一些功能,但是没有修改或者添加action的参数. 2. 数据库需要升级,执行了一些sql,修改过action的值. 3. 当修改某个已经存在的记录,然后 ...

  9. 问题:unknown error: call function result missing 'value' 解决方法

    问题:unknown error: call function result missing 'value' 页面也没有 填充信息 原因是:安装与chrome和对应的chromedriver版本问题 ...

  10. Yii2 给表添加字段后报错 Getting unknown property

    手动在数据库中添加了image字段 然后再模型类Image中的 rule方法也将image的验证规则放进去了 但是在 $model = new Image 后,使用$model->iamge 还 ...

随机推荐

  1. 后台管理系统的setting.js

    // 修改了此处要重新启动 module.exports = { // 网页的标题 title: "人力资源系统", /** * @type {boolean} true | fa ...

  2. 【Azure Cloud Service】使用Key Vault Secret添加.CER证书到Cloud Service Extended Support中

    问题描述 因为Key Vault的证书上传功能中,只支持pfx格式的证书,而中间证书,根证书不能转换为pfx格式,只能是公钥证书格式 cet 或者 crt,能通过文本工具直接查看base64编码内容. ...

  3. 云原生周刊:Kubernetes 1.30 的一切新功能 | 2024.4.1

    开源项目推荐 Kubernetes scheduler simulator 该项目是一个用于模拟 Kubernetes 调度器行为的开源项目,可用于测试和评估调度器的性能和行为.它提供了一个模拟集群和 ...

  4. DataDream:调一调更好,基于LoRA微调SD的训练集合成新方案 | ECCV'24

    尽管文本到图像的扩散模型已被证明在图像合成方面达到了最先进的结果,但它们尚未证明在下游应用中的有效性.先前的研究提出了在有限的真实数据访问下为图像分类器训练生成数据的方法.然而,这些方法在生成内部分布 ...

  5. PHP实现csv导出(多种方法对比及原理解析)

    前言 导出文件时,如果不需要任何复杂的Excel功能,请使用CSV 工作中最初遇到导出Excel的需求,都是使用的PHPExcel,它的功能非常强大,可以覆盖到绝大多数的定制化导出需求.也就一直用着了 ...

  6. 一个.NET开源、轻量级的运行耗时统计库 - MethodTimer

    前言 在.NET开发中,为了准确统计对应方法的执行时间,我们最常用的方式是手动使用 Stopwatch 来显式编写计时逻辑,但是假如你需要大量的使用 Stopwatch 来进行耗时统计的话不利于保持代 ...

  7. mysql skip-name-resolve 的解释

    PHP交流群  717902309 为PHP广大爱好者提供技术交流,有问必答,相互学习相互进步! mysql连接很慢,登陆到服务器上查看mysql日志:IP address 'XX.XX.XX.XX' ...

  8. .NetCore+Mysql+Vue+MVC+SqlSugar开源WMS仓库管理系统

    今天给大家推荐一个开源免费WMS仓库管理系统.仓库管理系统,可以有效控制并跟踪仓库业务的物流和成本管理全过程,实现或完善企业的仓储信息管理. 项目功能列表 基础数据 系统设置 物料管理 客户管理 供应 ...

  9. 鸿蒙hvigor构建任务依赖与生命周期简介

    Hivgor脚本文件 在构建的生命周期中Hvigor使用两个脚本文件来完成插件.任务以及生命周期hook的注册: hvigorconfig.ts:此文件在整个项目中只有根目录下存在一份,不是构建必须的 ...

  10. 2025年前端面试准备js篇

    1.js的基本数据类型有哪些 undefined,null,bo0lean,number,string,object,Symbol,bigInt 分为原始类型和引用类型 原始类型:undefined, ...