| <dependencies> |
| <dependency> |
| <groupId>org.springframework.boot</groupId> |
| <artifactId>spring-boot-starter-test</artifactId> |
| <version>2.6.1</version> |
| <scope>test</scope> |
| </dependency> |
| <dependency> |
| <groupId>org.springframework.boot</groupId> |
| <artifactId>spring-boot-starter-webflux</artifactId> |
| <version>2.6.1</version> |
| </dependency> |
| <dependency> |
| <groupId>com.baomidou</groupId> |
| <artifactId>mybatis-plus-boot-starter</artifactId> |
| <version>3.4.0</version> |
| </dependency> |
| <dependency> |
| <groupId>com.github.pagehelper</groupId> |
| <artifactId>pagehelper</artifactId> |
| <version>5.1.11</version> |
| </dependency> |
| <dependency> |
| <groupId>mysql</groupId> |
| <artifactId>mysql-connector-java</artifactId> |
| <version>8.0.27</version> |
| </dependency> |
| <dependency> |
| <groupId>org.projectlombok</groupId> |
| <artifactId>lombok</artifactId> |
| <version>1.18.18</version> |
| <scope>provided</scope> |
| </dependency> |
| </dependencies> |
| server: |
| port: 8080 |
| |
| spring: |
| application: |
| name: demo12 |
| datasource: |
| driver-class-name: com.mysql.cj.jdbc.Driver |
| url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8 |
| username: root |
| password: 123456 |
| main: |
| allow-circular-references: true |
| devtools: |
| restart: |
| enabled: true |
| |
| mybatis: |
| configuration: |
| map-underscore-to-camel-case: true |
| logging: |
| level: |
| com: |
| ychen: |
| mybatis: debug |
| @SpringBootApplication |
| @MapperScan(basePackages = "com.ychen.mybatis.mapper") |
| public class Demo12Application { |
| |
| public static void main(String[] args) { |
| SpringApplication.run(Demo12Application.class, args); |
| } |
| |
| } |
| @Configuration |
| public class MybatisPlusConfig { |
| |
| |
| |
| |
| @Bean |
| public MybatisPlusInterceptor mybatisPlusInterceptor() { |
| MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
| PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(); |
| paginationInnerInterceptor.setDbType(DbType.MYSQL); |
| paginationInnerInterceptor.setOverflow(true); |
| interceptor.addInnerInterceptor(paginationInnerInterceptor); |
| return interceptor; |
| } |
| |
| @Bean |
| public ConfigurationCustomizer configurationCustomizer() { |
| return configuration -> configuration.setUseDeprecatedExecutor(false); |
| } |
| |
| } |
| |
| @Configuration |
| public class MybatisPlusPageConfig { |
| |
| |
| |
| |
| @Bean |
| public PageInterceptor pageInterceptor() { |
| return new PageInterceptor(); |
| } |
| |
| } |
| @Data |
| public class User { |
| |
| private Long id; |
| |
| private String name; |
| } |
| @Mapper |
| public interface UserMapper extends BaseMapper<User> { |
| |
| } |
| @RestController |
| public class TestController { |
| |
| @Autowired |
| private UserMapper mapper; |
| |
| |
| |
| |
| |
| @RequestMapping("/test1") |
| @ResponseBody |
| public String test1(){ |
| Page<User> mpPage = mapper.selectPage( |
| new Page<>(1, 2), Wrappers.<User>query().eq("id", 1) |
| ); |
| List<User> records = mpPage.getRecords(); |
| System.out.println(records); |
| return "success"; |
| } |
| |
| |
| |
| |
| |
| @RequestMapping("/test2") |
| @ResponseBody |
| public String test2(){ |
| PageInfo<User> info = PageHelper.startPage( |
| 1, 2).doSelectPageInfo(() -> mapper.selectById(1) |
| ); |
| List<User> list = info.getList(); |
| System.out.println(list); |
| return "success"; |
| } |
| |
| @RequestMapping("/test3") |
| @ResponseBody |
| public String test3(){ |
| List<Long> ids = Arrays.asList(1L, 2L); |
| PageInfo<User> info = PageHelper.startPage(1, 5) |
| .doSelectPageInfo(() -> mapper.selectList(Wrappers.<User>query().in("id", ids))); |
| List<User> list = info.getList(); |
| System.out.println(list); |
| return "success"; |
| } |
| |
| } |
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术