crystalccc

crystalccc

No property named “id“ exists in source parameter(s)

在项目中同时使用 lombok 与 mapstruct 包的时候,写了一个 UserConvert,UserBO 与 UserDO 里面用了 @Getter@Setter 注解

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

解决方案#

在 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.10.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>1.5.0.RC1</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>1.18.24</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok-mapstruct-binding</artifactId>
                            <version>0.2.0</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
    </plugins>
</build>
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.