diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 4b6a7e3..0e952e0 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -12,9 +12,10 @@ + - + @@ -27,7 +28,8 @@ \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 60e00e0..4e23834 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -23,8 +23,9 @@ - - + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index 9b69f6c..3deae01 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -25,6 +25,8 @@ diff --git a/springboot-mbp-526/pom.xml b/springboot-mbp-526/pom.xml new file mode 100644 index 0000000..5e9a3f1 --- /dev/null +++ b/springboot-mbp-526/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.7.12 + + + com.example + springboot-mbp-526 + 0.0.1-SNAPSHOT + springboot-mbp-526 + springboot-mbp-526 + + 11 + + + + org.springframework.boot + spring-boot-starter-web + + + com.baomidou + mybatis-plus-boot-starter + 3.5.2 + + + com.mysql + mysql-connector-j + runtime + + + org.projectlombok + lombok + + + com.baomidou + mybatis-plus-generator + 3.5.2 + + + org.springframework.boot + spring-boot-starter-freemarker + + + + org.springframework.boot + spring-boot-starter-test + test + + + com.alibaba + druid-spring-boot-starter + 1.2.8 + + + org.springframework.boot + spring-boot-devtools + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/Application.java b/springboot-mbp-526/src/main/java/cn/czyx007/Application.java new file mode 100644 index 0000000..2fe949f --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/Application.java @@ -0,0 +1,13 @@ +package cn.czyx007; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/bean/Brand.java b/springboot-mbp-526/src/main/java/cn/czyx007/bean/Brand.java new file mode 100644 index 0000000..e56df06 --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/bean/Brand.java @@ -0,0 +1,100 @@ +package cn.czyx007.bean; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + *

+ * + *

+ * + * @author zyx + * @since 2023-05-26 + */ +@TableName("tb_brand") +public class Brand implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private String brandName; + + private String companyName; + + private Integer ordered; + + private String description; + + private Integer status; + + private LocalDateTime createDate; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + public String getBrandName() { + return brandName; + } + + public void setBrandName(String brandName) { + this.brandName = brandName; + } + public String getCompanyName() { + return companyName; + } + + public void setCompanyName(String companyName) { + this.companyName = companyName; + } + public Integer getOrdered() { + return ordered; + } + + public void setOrdered(Integer ordered) { + this.ordered = ordered; + } + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + public LocalDateTime getCreateDate() { + return createDate; + } + + public void setCreateDate(LocalDateTime createDate) { + this.createDate = createDate; + } + + @Override + public String toString() { + return "Brand{" + + "id=" + id + + ", brandName=" + brandName + + ", companyName=" + companyName + + ", ordered=" + ordered + + ", description=" + description + + ", status=" + status + + ", createDate=" + createDate + + "}"; + } +} diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/bean/User.java b/springboot-mbp-526/src/main/java/cn/czyx007/bean/User.java new file mode 100644 index 0000000..08d51ea --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/bean/User.java @@ -0,0 +1,48 @@ +package cn.czyx007.bean; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * (User)实体类 + * + * @author 张宇轩 + * @since 2023-05-25 15:30:24 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("user") +public class User implements Serializable { + private static final long serialVersionUID = 872728960100083467L; + /** + * 主键ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + /** + * 姓名 + */ + //exist=true表示是数据库表中的字段,默认为true + @TableField(value = "name", exist = true) + private String name; + /** + * 年龄 + */ + private Integer age; + /** + * 邮箱 + */ + private String email; + + //不是数据库表的字段 + @TableField(exist = false) + private String deptName; +} diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/config/MvcConfig.java b/springboot-mbp-526/src/main/java/cn/czyx007/config/MvcConfig.java new file mode 100644 index 0000000..f5aa390 --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/config/MvcConfig.java @@ -0,0 +1,17 @@ +package cn.czyx007.config; + +import cn.czyx007.interceptor.MyInterceptor; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * @author : 张宇轩 + * @createTime : 2023/5/26 - 16:13 + */ +//配置类,配置拦截器、redis、解决CORS跨域问题 +public class MvcConfig implements WebMvcConfigurer { + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**"); + } +} diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/config/MybatisPlusConfig.java b/springboot-mbp-526/src/main/java/cn/czyx007/config/MybatisPlusConfig.java new file mode 100644 index 0000000..e5e61ae --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/config/MybatisPlusConfig.java @@ -0,0 +1,21 @@ +package cn.czyx007.config; + +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author : 张宇轩 + * @createTime : 2023/5/26 - 14:25 + */ +@Configuration +public class MybatisPlusConfig { + //@Bean表示该方法返回的实例交给spring管理 + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor(){ + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); + return interceptor; + } +} diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/controller/BrandController.java b/springboot-mbp-526/src/main/java/cn/czyx007/controller/BrandController.java new file mode 100644 index 0000000..dd2ab92 --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/controller/BrandController.java @@ -0,0 +1,31 @@ +package cn.czyx007.controller; + +import cn.czyx007.bean.Brand; +import cn.czyx007.service.IBrandService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + *

+ * 前端控制器 + *

+ * + * @author zyx + * @since 2023-05-26 + */ +@RestController +@RequestMapping("/brand") +public class BrandController { + @Autowired + private IBrandService brandService; + + @GetMapping("/getBrand") + public List getBrand(){ + System.out.println("yeeee!!!周五了!"); + return brandService.list(); + } +} diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/interceptor/MyInterceptor.java b/springboot-mbp-526/src/main/java/cn/czyx007/interceptor/MyInterceptor.java new file mode 100644 index 0000000..5498f1b --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/interceptor/MyInterceptor.java @@ -0,0 +1,33 @@ +package cn.czyx007.interceptor; + +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author : 张宇轩 + * @createTime : 2023/5/26 - 16:07 + */ +public class MyInterceptor implements HandlerInterceptor { + //请求到达控制器之前执行此方法 + //返回true,请求通过,否则不通过 + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + System.out.println("preHandle执行..."); + return true; + } + + //请求已经到达了控制器,执行此方法 + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { + System.out.println("postHandle执行..."); + } + + //请求完成之后,执行此方法 + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + System.out.println("afterCompletion执行..."); + } +} diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/mapper/BrandMapper.java b/springboot-mbp-526/src/main/java/cn/czyx007/mapper/BrandMapper.java new file mode 100644 index 0000000..a5b8247 --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/mapper/BrandMapper.java @@ -0,0 +1,18 @@ +package cn.czyx007.mapper; + +import cn.czyx007.bean.Brand; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author zyx + * @since 2023-05-26 + */ +@Mapper +public interface BrandMapper extends BaseMapper { + +} diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/mapper/UserMapper.java b/springboot-mbp-526/src/main/java/cn/czyx007/mapper/UserMapper.java new file mode 100644 index 0000000..659f4ed --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/mapper/UserMapper.java @@ -0,0 +1,14 @@ +package cn.czyx007.mapper; + +import cn.czyx007.bean.User; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author : 张宇轩 + * @createTime : 2023/5/25 - 15:30 + */ +@Mapper +public interface UserMapper extends BaseMapper { + +} diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/service/IBrandService.java b/springboot-mbp-526/src/main/java/cn/czyx007/service/IBrandService.java new file mode 100644 index 0000000..49d1c22 --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/service/IBrandService.java @@ -0,0 +1,16 @@ +package cn.czyx007.service; + +import cn.czyx007.bean.Brand; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author zyx + * @since 2023-05-26 + */ +public interface IBrandService extends IService { + +} diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/service/UserService.java b/springboot-mbp-526/src/main/java/cn/czyx007/service/UserService.java new file mode 100644 index 0000000..b1f2c14 --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/service/UserService.java @@ -0,0 +1,12 @@ +package cn.czyx007.service; + +import cn.czyx007.bean.User; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * @author : 张宇轩 + * @createTime : 2023/5/26 - 11:35 + */ +public interface UserService extends IService { + +} diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/service/impl/BrandServiceImpl.java b/springboot-mbp-526/src/main/java/cn/czyx007/service/impl/BrandServiceImpl.java new file mode 100644 index 0000000..fe66c4d --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/service/impl/BrandServiceImpl.java @@ -0,0 +1,20 @@ +package cn.czyx007.service.impl; + +import cn.czyx007.bean.Brand; +import cn.czyx007.mapper.BrandMapper; +import cn.czyx007.service.IBrandService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author zyx + * @since 2023-05-26 + */ +@Service +public class BrandServiceImpl extends ServiceImpl implements IBrandService { + +} diff --git a/springboot-mbp-526/src/main/java/cn/czyx007/service/impl/UserServiceImpl.java b/springboot-mbp-526/src/main/java/cn/czyx007/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..edd4cc2 --- /dev/null +++ b/springboot-mbp-526/src/main/java/cn/czyx007/service/impl/UserServiceImpl.java @@ -0,0 +1,18 @@ +package cn.czyx007.service.impl; + +import cn.czyx007.bean.User; +import cn.czyx007.mapper.UserMapper; +import cn.czyx007.service.UserService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author : 张宇轩 + * @createTime : 2023/5/26 - 11:38 + */ +@Service +@Transactional +public class UserServiceImpl extends ServiceImpl implements UserService { + +} diff --git a/springboot-mbp-526/src/main/resources/application.yml b/springboot-mbp-526/src/main/resources/application.yml new file mode 100644 index 0000000..0cf1e26 --- /dev/null +++ b/springboot-mbp-526/src/main/resources/application.yml @@ -0,0 +1,28 @@ +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/person_info?serverTimezone=Asia/Shanghai + username: root + password: zyx007 + druid: + #初始化连接数 + initial-size: 1 + #最小空闲连接 + min-idle: 1 + #最大活动连接 + max-active: 20 + #获取连接时测试是否可用 + test-on-borrow: true + #监控页面启动 + filter: + wall: + config: + start-transaction-allow: true +# web: +# resources: +# #修改静态资源目录 +# static-locations: classpath:/liuyan/ + +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl diff --git a/springboot-mbp-526/src/main/resources/liuyan/img.png b/springboot-mbp-526/src/main/resources/liuyan/img.png new file mode 100644 index 0000000..3801dff Binary files /dev/null and b/springboot-mbp-526/src/main/resources/liuyan/img.png differ diff --git a/springboot-mbp-526/src/test/java/cn/czyx007/ApplicationTests.java b/springboot-mbp-526/src/test/java/cn/czyx007/ApplicationTests.java new file mode 100644 index 0000000..53fbddd --- /dev/null +++ b/springboot-mbp-526/src/test/java/cn/czyx007/ApplicationTests.java @@ -0,0 +1,84 @@ +package cn.czyx007; + +import cn.czyx007.bean.User; +import cn.czyx007.mapper.UserMapper; +import cn.czyx007.service.UserService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.generator.FastAutoGenerator; +import com.baomidou.mybatisplus.generator.config.OutputFile; +import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; +import com.mysql.cj.util.StringUtils; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.Collections; +import java.util.List; + +@SpringBootTest +class ApplicationTests { + + @Autowired + private UserMapper userMapper; + + @Autowired + private UserService userService; + + @Test + void contextLoads() { + List users = userMapper.selectList(null); + users.forEach(System.out::println); + } + + @Test + void test2(){ + String name = "J"; + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.like(!StringUtils.isNullOrEmpty(name), User::getName, name); + List user = userMapper.selectList(lqw); + user.forEach(System.out::println); + } + + @Test + void test3(){ + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.like(User::getName, "J"); + userService.list(lqw).forEach(System.out::println); + } + + @Test + void test4(){ + //创建一个mybatisplus的分页对象 + IPage iPage = new Page<>(1, 2); + //进行查询 + userService.page(iPage); + //输出结果 + System.out.println("分页数据:" + iPage.getRecords()); + System.out.println("页数:" + iPage.getPages()); + System.out.println("记录数:" + iPage.getTotal()); + } + + @Test + void test5(){ + FastAutoGenerator.create("jdbc:mysql://localhost:3306/person_info?serverTimezone=Asia/Shanghai", + "root", "zyx007") + .globalConfig(builder -> { + builder.author("zyx") // 设置作者 +// .enableSwagger() // 开启 swagger 模式 + .outputDir("C:\\Users\\zyx\\Desktop\\课程文件\\大三\\下学期\\生产实习\\ProductionPractice\\springboot-mbp-526\\src\\main\\java\\cn\\czyx007"); // 指定输出目录 + }) + .packageConfig(builder -> { + builder.parent("demo") // 设置父包名 +// .moduleName("system") // 设置父包模块名 + .pathInfo(Collections.singletonMap(OutputFile.xml, "C:\\Users\\zyx\\Desktop\\课程文件\\大三\\下学期\\生产实习\\ProductionPractice\\springboot-mbp-526\\src\\main\\resources\\mappers")); // 设置mapperXml生成路径 + }) + .strategyConfig(builder -> { + builder.addInclude("tb_brand") // 设置需要生成的表名 + .addTablePrefix("tb_"); // 设置过滤表前缀 + }) + .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板 + .execute(); + } +} diff --git a/springboot525/pom.xml b/springboot525-526/pom.xml similarity index 86% rename from springboot525/pom.xml rename to springboot525-526/pom.xml index fb357b8..e8fd776 100644 --- a/springboot525/pom.xml +++ b/springboot525-526/pom.xml @@ -9,10 +9,10 @@ com.example - springboot525 + springboot525-526 0.0.1-SNAPSHOT - springboot525 - springboot525 + springboot525-526 + springboot525-526 11 @@ -42,6 +42,11 @@ mybatis-spring-boot-starter 2.2.2 + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.4.6 + diff --git a/springboot525/src/main/java/cn/czyx007/Application.java b/springboot525-526/src/main/java/cn/czyx007/Application.java similarity index 100% rename from springboot525/src/main/java/cn/czyx007/Application.java rename to springboot525-526/src/main/java/cn/czyx007/Application.java diff --git a/springboot525/src/main/java/cn/czyx007/bean/Person.java b/springboot525-526/src/main/java/cn/czyx007/bean/Person.java similarity index 100% rename from springboot525/src/main/java/cn/czyx007/bean/Person.java rename to springboot525-526/src/main/java/cn/czyx007/bean/Person.java diff --git a/springboot525/src/main/java/cn/czyx007/bean/User.java b/springboot525-526/src/main/java/cn/czyx007/bean/User.java similarity index 100% rename from springboot525/src/main/java/cn/czyx007/bean/User.java rename to springboot525-526/src/main/java/cn/czyx007/bean/User.java diff --git a/springboot525/src/main/java/cn/czyx007/controller/HelloController.java b/springboot525-526/src/main/java/cn/czyx007/controller/HelloController.java similarity index 100% rename from springboot525/src/main/java/cn/czyx007/controller/HelloController.java rename to springboot525-526/src/main/java/cn/czyx007/controller/HelloController.java diff --git a/springboot525/src/main/java/cn/czyx007/mapper/UserMapper.java b/springboot525-526/src/main/java/cn/czyx007/mapper/UserMapper.java similarity index 100% rename from springboot525/src/main/java/cn/czyx007/mapper/UserMapper.java rename to springboot525-526/src/main/java/cn/czyx007/mapper/UserMapper.java diff --git a/springboot525/src/main/java/cn/czyx007/service/UserService.java b/springboot525-526/src/main/java/cn/czyx007/service/UserService.java similarity index 100% rename from springboot525/src/main/java/cn/czyx007/service/UserService.java rename to springboot525-526/src/main/java/cn/czyx007/service/UserService.java diff --git a/springboot525/src/main/java/cn/czyx007/service/impl/UserServiceImpl.java b/springboot525-526/src/main/java/cn/czyx007/service/impl/UserServiceImpl.java similarity index 100% rename from springboot525/src/main/java/cn/czyx007/service/impl/UserServiceImpl.java rename to springboot525-526/src/main/java/cn/czyx007/service/impl/UserServiceImpl.java diff --git a/springboot525/src/main/resources/application.yml b/springboot525-526/src/main/resources/application.yml similarity index 77% rename from springboot525/src/main/resources/application.yml rename to springboot525-526/src/main/resources/application.yml index 78b5110..fe1e127 100644 --- a/springboot525/src/main/resources/application.yml +++ b/springboot525-526/src/main/resources/application.yml @@ -11,5 +11,11 @@ mybatis: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl +pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: true + params: count=countSql + person: username: abc diff --git a/springboot525/src/main/resources/mappers/userMapper.xml b/springboot525-526/src/main/resources/mappers/userMapper.xml similarity index 100% rename from springboot525/src/main/resources/mappers/userMapper.xml rename to springboot525-526/src/main/resources/mappers/userMapper.xml diff --git a/springboot525-526/src/test/java/cn/czyx007/ApplicationTests.java b/springboot525-526/src/test/java/cn/czyx007/ApplicationTests.java new file mode 100644 index 0000000..82352eb --- /dev/null +++ b/springboot525-526/src/test/java/cn/czyx007/ApplicationTests.java @@ -0,0 +1,32 @@ +package cn.czyx007; + +import cn.czyx007.bean.User; +import cn.czyx007.service.UserService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.List; + +@SpringBootTest +class ApplicationTests { + + @Autowired + private UserService userService; + + @Test + void contextLoads() { + //开启分页查询 + PageHelper.startPage(1,2); + //查询数据 + List user = userService.findUser(); + PageInfo pageInfo = new PageInfo<>(user); + List list = pageInfo.getList(); + list.forEach(System.out::println); + + System.out.println("页数 = " + pageInfo.getPages()); + } + +} diff --git a/springboot525/src/test/java/cn/czyx007/ApplicationTests.java b/springboot525/src/test/java/cn/czyx007/ApplicationTests.java deleted file mode 100644 index 9968ed0..0000000 --- a/springboot525/src/test/java/cn/czyx007/ApplicationTests.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.czyx007; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class ApplicationTests { - - @Test - void contextLoads() { - - } - -}