org.dozer.MappingException: class 中未找到字段 (metaClass) 的读取或写入方法

org.dozer.MappingException: No read or write method found for field (metaClass) in class

当我 运行 我的 spring 引导应用程序时出现此错误。 谁能告诉我如何解决它?

我的SpringBoot项目是基于Groovy和Gradle.

错误提示如下

16:18:37.215 [http-nio-9092-exec-5] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] 
- Servlet.service() for servlet [dispatcherServlet] in context with path [] 
threw exception [Request processing failed; nested exception is 
org.codehaus.groovy.runtime.typehandling.GroovyCastException: 
Cannot cast object 'org.dozer.MappingException: 
No read or write method found for field (metaClass) in class (class com.myapp.Orders)' 
with class 'org.dozer.MappingException' to class 'java.util.Map'] with root cause

我在 class(com.myapp.Orders) 中没有元类字段。 class(com.myapp.Orders.groovy) 如下所示

import lombok.Getter
import lombok.Setter
@Getter
@Setter
class Orders {
    long orderId
    String kNo
    String sOrderCode
    int orderStatus
    String deliveryTypeCode
    String receiverFullName
    Date orderAt
}

目的地class(com.myapp.AfOrders.groovy)如下

import lombok.Getter
import lombok.Setter
@Getter
@Setter
class AfOrders {
    String kNo
    String sOrderCode
    int orderStatus
    String deliveryTypeCode
    String receiverFullName
    Date orderAt
    String fType
}

我的build.gradle如下

buildscript {
    ext {
        springBootVersion = '2.0.0.RELEASE'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
        maven { url 'http://jcenter.bintray.com' }
    }
    dependencies {
        classpath("io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE")
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath("mysql:mysql-connector-java:5.1.45")
        classpath ("org.junit.platform:junit-platform-gradle-plugin:1.1.0")
    }
}

apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.junit.platform.gradle.plugin'

group = 'com.myapp'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {

    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-data-rest')

    compile('org.springframework.boot:spring-boot-starter-web') 
    compile('org.springframework.boot:spring-boot-starter-webflux')

    compile('org.springframework.boot:spring-boot-starter-security')
    testCompile('org.springframework.security:spring-security-test')

    compile('org.flywaydb:flyway-core')
    compile('org.springframework.data:spring-data-rest-hal-browser')
    compile('org.codehaus.groovy:groovy')
    runtime('mysql:mysql-connector-java')
    compileOnly('org.projectlombok:lombok')

    compile('org.springframework.boot:spring-boot-starter-jdbc')
    compile('mysql:mysql-connector-java:5.1.45')
    runtime('mysql:mysql-connector-java:5.1.45')

    compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1')

    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1')
    compile('org.hibernate:hibernate-validator:6.0.8.Final')

    compile('net.sf.dozer:dozer:5.5.1')
    compile('net.sf.dozer:dozer-spring:5.5.1')

}

我的配置文件如下

<?xml version="1.0" encoding="UTF-8"?>
<mappings xmlns="http://dozer.sourceforge.net"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://dozer.sourceforge.net
      http://dozer.sourceforge.net/schema/beanmapping.xsd">
    <mapping map-null="false">
        <class-a>com.myapp.Orders</class-a>
        <class-b>com.myapp.AfOrders</class-b>
        <field-exclude type="one-way"> 
            <a>metaClass</a> 
            <b>metaClass</b> 
        </field-exclude>
    </mapping>
</mappings>

我删除了 "one-way",有效!