org.mapstruct.Mapper与org.apache.ibatis.annotations.Mapper | 您所在的位置:网站首页 › mapper和mapperscan会冲突吗 › org.mapstruct.Mapper与org.apache.ibatis.annotations.Mapper |
org.mapstruct.Mapper: 这是 MapStruct 映射框架提供的注解,用于标记接口或抽象类为 MapStruct 的映射器接口。MapStruct 是一个 Java 映射工具,可以帮助开发者方便地进行 Java Bean 之间的映射转换。通过在接口或抽象类上添加 @Mapper 注解,可以告诉 MapStruct 框架该接口或抽象类是一个映射器,需要根据其中定义的映射方法自动生成映射代码。 示例: import org.mapstruct.Mapper; @Mapper public interface UserMapper { UserDto userToUserDto(User user); }org.apache.ibatis.annotations.Mapper: 这是 MyBatis 持久层框架提供的注解,用于标记接口为 MyBatis 的映射器接口。MyBatis 是一个优秀的持久层框架,通过 XML 配置文件或注解方式可以方便地编写 SQL 映射语句,并将 Java 对象映射到数据库表中。 示例: import org.apache.ibatis.annotations.Mapper; @Mapper public interface UserMapper { User getUserById(Long id); } |
CopyRight 2018-2019 实验室设备网 版权所有 |