Maven java: The type of parameter "xxx" has no property named "id".

Maven Lombok MapStruct About 1,547 words

错误信息

java: The type of parameter "xxx" has no property named "id".

原因

Lombox中的settergetter方法,在MapStruct中没有找到。

解决方法

方法一

pom.xmlLombok依赖顺序写在MapStruct前面。

方法二

使用老版本LombokMapStruct

<lombok.version>1.18.12</lombok.version>
<mapstruct.version>1.3.1.Final</mapstruct.version>

方法三

plugin中添加lombok-mapstruct-binding

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <source>11</source>
        <target>11</target>
        <annotationProcessorPaths>
            <path>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct-processor</artifactId>
                <version>1.4.2.Final</version>
            </path>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.12</version>
            </path>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok-mapstruct-binding</artifactId>
                <version>0.2.0</version>
            </path>
        </annotationProcessorPaths>
    </configuration>
</plugin>

参考

https://mapstruct.org/faq/#Can-I-use-MapStruct-together-with-Project-Lombok

Views: 3,152 · Posted: 2022-07-21

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh