我正在尝试在我的 Play 2.4 Java8 JPA 项目中使用 mapstruct。我已经完成的步骤:
添加依赖项
"org.mapstruct" % "mapstruct-jdk8" % "1.1.0.Beta1",
"org.mapstruct" % "mapstruct-processor" % "1.1.0.Beta1"
模型
@Entity
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String fullName;
private String email;
}
员工Dto
public class EmployeeDto {
private String full_name;
private String email;
}
员工映射器
@Mapper
public interface EmployeeMapper {
EmployeeMapper INSTANCE = Mappers.getMapper(EmployeeMapper.class);
@Mapping(source = "fullName", target = "full_name")
EmployeeDto employeeToEmployeeDto(Employee employee);
}
但它给了我一个编译错误
error: Unknown property "full_name" in return type.
[error] @Mapping(source = "fullName", target = "full_name")
错误可能是什么问题?