是什么?
是一个类转换框架,用于将do–>vo。这种的相互转换,替换BeanUtils的copy方法
为什么选他?
1、抽象出来转换接口,方便维护
2、可读性高,几个注解即可
3、性能高,其原理是在编译时期,将接口实现,而不是通过反射获取属性调用接口。
怎么用?
maven
<properties>
<org.mapstruct.version>1.3.1.Final</org.mapstruct.version>
</properties>
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source> <!-- depending on your project -->
<target>1.8</target> <!-- depending on your project -->
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>