java 尝试使用maven编译项目时, MapStruct 报错:
@Mapper
public interface MedicalRecordConverter extends Mapper {
MedicalRecordConverter INSTANCE = Mappers.getMapper(MedicalRecordConverter.class);
@Mappings({
// @Mapping(source = "visitGuid", target = "visitGuid", defaultValue = "默认值")//,
// @Mapping(target = "createUserCode", expression = "java(com.hutao.manage.test.mapstruct.MapStructUtil.getCreateUser( medicalRecord.createUserCode))")//,
// @Mapping(target = "createUserName", expression = "java(com.hutao.manage.test.mapstruct.MapStructUtil.getCase( medicalRecord.createUserName))"),
// @Mapping(target = "pigeonholeUserCode", defaultValue = "java(com.hutao.manage.test.mapstruct.MapStructUtil.getCase())")
})
PigeonholeRecord meToPige (MedicalRecord medicalRecord);
}
报错为:
Can't generate mapping method with no input arguments.
得了。。。代码copy过去一看,明白了,一个是注解的
@Mapper
,一个是继承的Mapper
@Mapper
就是注解不是一个接口,虽然语法没有报错,但是实际上使用是无效的Mapper
的接口,在同一源文件中有同名类的情况下应该是这样的模式,也就是有一个是加包名的总之,如果你看了官方文档,就会发现你这种写法压根就没有