1.操作总概括

2.导入 pom.xml 依赖

3.启动类添加注解扫描 持久化文件
//扫描的是mapper.xml中namespace指向值的包位置

4. application.properties 配置数据库信息
# 数据库操作
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
5.持久化文件编写
字段名对应,看最后驼峰式命名

6.配置分页插件
public PageHelper pageHelper() {
System.out.println("pageHelper");
PageHelper pageHelper = new PageHelper();
Properties properties = new Properties();
// 设置参数
properties.setProperty("offsetAsPageNum", "true");
properties.setProperty("rowBoundsWithCount", "true");
properties.setProperty("reasonable", "true");
pageHelper.setProperties(properties);
return pageHelper;
}

7.分页设置

8.事物添加, Service 的增删改方法添加注解@Transactional
9.开启驼峰命名


网友评论