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. C# 新语法 switch 的简单写法

    // C# 中的新语法 switch 的简写 string str = "123"; string res = str switch { "1" => & ...

  2. js的作用域有哪些 and 他们的特点

    全局作用域:是所有代码的执行环境,比如script标签里所有的代码 或 独立的js 文件: 局部作用域:是函数内部代码的执行环境: 块级作用域:是 {} 内的代码执行环境:

  3. 工作使用:Exchange命令集(超级重要)

    工作使用:Exchange命令集(超级重要) 命令1:导出某个用户的邮件                  New-MailboxExportRequest   -mailbox  dusonglin ...

  4. 自学PHP笔记(四) PHP变量和常量

    PHP中变量有普通变量.可变变量和预定义变量,而常量就是普通变量和预定义变量. 1. 变量 在PHP中变量是内存中得一个命名单元,在系统中为程序中每个变量都分配一个存储单元,在这些存储单元中可以存储任 ...

  5. 欢迎来到IoT解忧杂货铺

    这是一间特殊的杂货铺 门面不大,却包罗万物 如果你也遇到一些烦恼 欢迎来到,IoT解忧杂货铺 解忧秘方·工业 厂里的几十台设备真让人头疼 协议种类太多太复杂 设备没法全联网 产线故障了也不知道 自己出 ...

  6. 初探python栈帧逃逸

    前言 以前在一些大型比赛就遇到这种题,一直没时间去研究,现在康复训练下:) 生成器介绍 生成器(Generator)是Python中一种特殊的迭代器,它可以在迭代过程中动态生成值,而不需要一次性将所有 ...

  7. ES6语法特性

    ES6语法特性 简介 ECMAScript 6.0(以下简称 ES6)是 JavaScript 语言的下一代标准,已经在 2015 年 6 月正式发布了. 它的目标,是使得 JavaScript 语言 ...

  8. 《JVM第6课》本地方法栈

    1 什么是本地方法 首先要知道什么是本地方法,本地方法并不是 JVM 自己的方法,也不是 jre 里面的方法,而是指那些操作系统自己的方法(如C/C++方法),它们在操作系统目录里.可以这么理解,本地 ...

  9. 海外SRC信息收集工具

    海外SRC信息收集 ​ 子域名爆破工具:bbot,subfinder ​ 相关测评:https://blog.blacklanternsecurity.com/p/subdomain-enumerat ...

  10. 认识鸿蒙Context

    Context是应用中对象的上下文,其提供了应用的一些基础信息,例如resourceManager(资源管理).applicationInfo(当前应用信息).dir(应用文件路径).area(文件分 ...