BeanUtils.copyProperties 性能慢
原创
©著作权归作者所有:来自51CTO博客作者谪归GL的原创作品,请联系作者获取转载授权,否则将追究法律责任
暂时不看原因,使用MapStruct 解决
使用流程:
1.idea 安装 MapStruct Support 插件(未测试是否为必要条件,推测不必要)
2.引入jar包
<!--mapstruct核心-->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.5.0.Beta1</version>
</dependency>
<!--mapstruct编译, 根据@Mapper注解生成对应的conver方法-->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.5.0.Beta1</version>
</dependency>
3.使用案例
描述: 只需要创建接口,接口实现类会在编译时自动生成
// 创建接口
@Mapper
public interface NsclientCopyMapper {
NsclientCopyMapper instance = (NsclientCopyMapper)Mappers.getMapper(NsclientCopyMapper.class);
NsclientView conver(NsclientView nsclientView);
}