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. USB 同步字段中高速同步字段和低速全速同步字段的区别

    USB(Universal Serial Bus)有几种不同的传输模式:低速(Low-Speed).全速(Full-Speed).高速(High-Speed)和超级速度(SuperSpeed).同步字 ...

  2. SURF (Speeded Up Robust Features,加速稳健特征)

    本篇文章来自wikipedia,如果需要阅读英文,可以去看一下. SURF (Speeded Up Robust Features, 加速稳健特征) 是一个稳健的图像识别和描述算法,首先于2006年发 ...

  3. 在实例化对象的时候new关键字具体做了哪些操作?

    a 创建了一个空对象 {}b 通过原型链把空对象和构造函数连接起来__proto__ = prototype c 构造函数的this指向新对象,并执行函数体 d 判断构造函数的返回值,返回对象就使用该 ...

  4. Vue3 的 nextTick 函数

    作用: DOM 渲染是异步耗时的, vue2.x 需要等到 DOM 渲染完成之后做某个事情,需要使用 this.$nextTick , vue3.x 则直接提供了 nextTick 这个方法去实现 : ...

  5. kali Linux 安装 AWVS 笔记

    安装 AWVS 笔记 配置安装 https://www.zwnblog.com/archives/kali-an-zhuang-awvs 根据这篇文章 配置并安装出来的 设定的账号和密码 账号:adm ...

  6. 【ZROJ2730】简单题 可持久化分块题解

    Description 给定一棵 \(n\) 个节点的树,每次询问编号为 \([l, r]\) 的点中有多少个是祖先关系. \(n, q \le 10^5\). Solution 直接做的话树上的祖先 ...

  7. keycloak~token有效期与session有效期

    一 refresh_token刷新access_token Keycloak会话管理中,获取到accessToken和refreshToken后,基于accessToken交换用户数据或者参与Keyc ...

  8. 图菱科技 SaaS 系统容器化最佳实践

    大家好,我是龚承明,在图菱(成都)科技有限公司任职,主要负责公司的产品系统研发以及公司IT基础设施的建设工作.本篇文章将为大家介绍下我司在采用 KubeSphere 平台实现公司业务系统容器化过程中的 ...

  9. 云原生爱好者周刊:使用 Cilium 和 Grafana 实现无侵入可观测性

    开源项目推荐 Cilium Grafana Observability Demo 这个项目由 Cilium 母公司 Isovalent 开源,提供了一个 Demo,使用 Cilium.OpenTele ...

  10. 分享一个大模型在请求api接口上的巧用

    前言 自从Chatgpt横空出世以来,各种智能工具层出不穷,聊天.绘画.视频等各种工具帮助很多人高效的工作.作为一个开发者,目前常用应用包括代码自动填充,聊天助手等. 这些是工具层面的使用,有没有将大 ...