关于java:mapStruct使用

27次阅读

共计 621 个字符,预计需要花费 2 分钟才能阅读完成。

// 引入依赖
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>1.2.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct-processor</artifactId>
            <version>1.2.0.Final</version>
        </dependency>


// 编写接口类
@Mapper
public interface Publish2PublishVO {Publish2PublishVO INSTANCE = Mappers.getMapper(Publish2PublishVO.class);

    CenterProductDataPublishVO toCenterProductDataPublishVO(CenterProductDataPublish centerProductDataPublish);

}


// 调用应用
CenterProductDataPublishVO centerProductDataPublishVO = Publish2PublishVO.INSTANCE.toCenterProductDataPublishVO(centerProductDataPublish);

正文完
 0