Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?

简介: Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?

Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?

问题描述

这里是引用

在项目中同时使用 lombok 与mapstruct 包的时候,写了一个mapper,Log与LogDTO里面用了@Getter、@Setter注解

在运行的时候报错 Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?

Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface LogMapper {
    @Mappings({
            @Mapping(source = "id", target = "idDTO"),
            @Mapping(source = "realName", target = "realNameDTO"),
            @Mapping(source = "name", target = "nameDTO"),
    })
    LogDTO convertToDTO(Log log);
    @Mappings({
            @Mapping(source = "idDTO", target = "id"),
            @Mapping(source = "realNameDTO", target = "realName"),
            @Mapping(source = "nameDTO", target = "name"),
            @Mapping(target = "address", constant = "无地址"),
    })
    Log covertToDO(LogDTO logDTO);
}

问题处理

查询了一些资料,有以下几种解决办法,针对我这个情况,是 采用了第三种解决办法,最有效的是下这种

(1)在pom文件中 加入binding 插件

pom.xml -> build-> plugins 下加入 lombok-mapstruct-binding

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.mapstruct</groupId>
                        <artifactId>mapstruct-processor</artifactId>
                        <version>1.3.1.Final</version>
                    </path>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>1.18.14</version>
                        <!--注意这里的版本号,建议不一样的,要改的和我一样,不然-->
                    </path>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok-mapstruct-binding</artifactId>
                        <version>0.2.0</version>
                        <!--注意这里的版本号,不要更改,用阿里云镜像的,他里面只有这个版本的文件,不然依旧报错-->
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
    </plugins>
</build>
其他的就不介绍的了,我试了只有他最有效
目录
相关文章
|
2月前
|
消息中间件 NoSQL Kafka
实时计算 Flink版产品使用合集之在进行全量同步时,有两张表的数据没有正确进入,并且ID字段为null,该怎么处理
实时计算Flink版作为一种强大的流处理和批处理统一的计算框架,广泛应用于各种需要实时数据处理和分析的场景。实时计算Flink版通常结合SQL接口、DataStream API、以及与上下游数据源和存储系统的丰富连接器,提供了一套全面的解决方案,以应对各种实时计算需求。其低延迟、高吞吐、容错性强的特点,使其成为众多企业和组织实时数据处理首选的技术平台。以下是实时计算Flink版的一些典型使用合集。
### Cause: java.sql.SQLException: Field ‘id‘ doesn‘t have a default value; Field ‘id‘ doesn‘t have
### Cause: java.sql.SQLException: Field ‘id‘ doesn‘t have a default value; Field ‘id‘ doesn‘t have
|
3天前
|
SQL Java 数据库连接
Cause: java.sql.SQLException: Field ‘id‘ doesn‘t have a default value; Field ‘id‘ doesn‘t have a de
Cause: java.sql.SQLException: Field ‘id‘ doesn‘t have a default value; Field ‘id‘ doesn‘t have a de
|
3天前
|
JSON Java 数据格式
前后端数据交换,JSON基础语法和JSON数据和Java对象转换,最快的对象转换,JSON{““}字符串如何写User{id=1,username=‘zhangsan‘,password=‘123‘}
前后端数据交换,JSON基础语法和JSON数据和Java对象转换,最快的对象转换,JSON{““}字符串如何写User{id=1,username=‘zhangsan‘,password=‘123‘}
|
1月前
|
Java
JAVA生成根据用户id唯一订单号,并发下唯一
JAVA生成根据用户id唯一订单号,并发下唯一
|
2月前
Cause: java.sql.SQLIntegrityConstraintViolationException: Column ‘id‘ in field list is ambiguous
Cause: java.sql.SQLIntegrityConstraintViolationException: Column ‘id‘ in field list is ambiguous
33 0
|
Java
Java 中 String 的 isEmpty() 与 null 与 "" 区别解析
问:简单说说 String 的 isEmpty() 与 null 与 "" 的区别? 答:回答这个问题的最好答案就是代码举例。
1119 0
|
Java 关系型数据库 Oracle
|
Java C语言 安全
java 的""和null的区别
null和""的区别 问题一: null和""的区别 String s=null; string.trim()就会抛出为空的exception String s=""; string.trim()就不会抛,为什么? 答: NULL代表声明了一个空对象,根本就不是一个字符串。
900 0