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. 世界第一!华为云图引擎服务GES大幅刷新世界纪录

    近日,国际关联数据基准委员会(Linked Data Benchmark Council,以下简称LDBC)公布了社交网络测试交互式负载(SNB INTERACTIVE WORKLOAD,以下简称为S ...

  2. python中模块的概念以及常用模块

    模块的概念:为了减少常用代码重复输入,同时方便多人协作,python中定义了模块一词. 模块是一些函数的集合.在python中可以使用import导入某一模块的单个或者所有功能. python中的模块 ...

  3. python实现链表(单链,双链)

    # code:utf-8 # createTime:2023.8.17 # -------------------------------------------------------------- ...

  4. 一个查询IP地理信息和CDN提供商的离线终端工具

    一个查询IP地理信息和CDN提供商的离线终端工具 Nali 功能 支持多种数据库 纯真 IPv4 离线数据库 ZX IPv6 离线数据库 Geoip2 城市数据库 (可选) IPIP 数据库 (可选) ...

  5. 快来考试拿证书!KubeSphere 个人技能专业考试认证上线啦!

    以容器技术和容器编排为基础的云原生应用,被越来越多的企业用户接受和使用,并且在生产环境中使用容器技术的比例逐年增加.Kubernetes 无疑已经成为容器编排的事实基础,而依托于 Kubernetes ...

  6. 云原生周刊:Dapr v1.11 发布

    开源项目推荐 Kamaji Kamaji 可以大规模地部署和运行 Kubernetes 控制平面,而只需承担一小部分操作负担.Kamaji 的特别之处在于,控制平面组件是在一个单一的 pod 中运行, ...

  7. Hugging Face国内镜像站:告别Hugging Face模型下载难题

    Hugging Face国内镜像站: https://hf-mirror.com/

  8. Go语言切片(Slice)的一些有趣特性

    切片类似数组的引用.更改底层数组中的元素会修改切片的元素.更改切片的元素同样会修改其底层数组中的元素,和它共享底层数组的切片都会观测到这些修改. 点击查看代码 package main import ...

  9. 使用wxpython开发跨平台桌面应用,动态工具的创建处理

    在我们开发系统的时候,往往需要一个很容易理解功能的工具栏,工具栏是一个系统的快速入口,美观易用的工具栏是可以给系统程序增色不少的,本篇随笔介绍在使用wxpython开发跨平台桌面应用,工具栏的动态展现 ...

  10. 12.Kubernetes集群安全机制

    Kubernetes集群安全机制 概述 当我们访问K8S集群时,需要经过三个步骤完成具体操作 认证 鉴权[授权] 准入控制 进行访问的时候,都需要经过 apiserver, apiserver做统一协 ...