初步解决了,但较奇怪的是,我是通过注释掉@Mapper,然后clean,再解开注释Mapper就可以了,这是什么原理哈?
老师,针对cource3这个mapstruct 一直生成这个代码,然后就是一直都是null,clean之后运行也还是这样,应该如何处理?
public class MetadataCopierImpl implements MetadataCopier {
@Override
public Metadata3 copy(DataCenterMetadata3 metadata) {
if ( metadata == null ) {
return null;
}
Metadata3 metadata3 = new Metadata3();
return metadata3;
}
}
Metadata3
@Slf4j
@Data
@NoArgsConstructor
public class Metadata3 implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 指标规则主键id
*/
private Long ruleId;
/**
* 指标英文标识
*/
private String enName;
}
DataCenterMetadata3
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class DataCenterMetadata3 implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId
private Long id;
/**
* 指标规则主键id
*/
private int ruleId;
/**
* 指标英文标识
*/
private Integer enName;
}
MetadataCopier
目前遇到的问题就是需要是不是重新注释一下这个@Mapper,不然会报错
// 用输入输出类型自动判断
//@Mapper(uses = DateMapper.class)
public interface MetadataCopier {
// @Mapping(source = "myDate", target = "myDate", dateFormat = "yyyyMMdd HH:mm:ss")
@Mapping(source = "createTime", target = "createTime", dateFormat = "yyyy/MM/dd HH:mm:ss")
@Mapping(source = "priceMax", target = "priceMax", numberFormat = "#.##E0")
@Mapping(source = "price", target = "price", numberFormat = "$#.00")
Metadata3 copy(DataCenterMetadata3 metadata);
MetadataCopier INSTANCE = Mappers.getMapper(MetadataCopier.class);
}