【Note_01】通用 mapper
一、通用 mapper 简介 最初我们手写 Mybatis 的 mapper.xml 文件,然后使用 Mybatis-generator 逆向工程生成 mapper.xml 文件,再发展到使用通用 mapper,支持自动生成 EntityMapper、mapper.xml 文件。 二、入门 Demo 1.引入依赖 <dependency> <groupId>tk.mybatis</groupId> <artifactId>mapper</artifactId> <version>最新版本</version> </dependency> 2.配置 Mybatis.xml 文件 <!-- 与 Mybatis 配置的区别仅仅是将 class="org.xxx" 改为了 class="tk.xxx" --> <bean class="tk.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="扫描包名"/> <!-- 其他配置 --> </bean> 3.实体类配置 public class Entity implements Serializable { @Id private Long id; private String name; //setter 和 getter