Spring Boot 2.x 小新功能 – Spring Data Web configuration

本文提纲

一、前言

二、运行 chapter-5-spring-boot-paging-sorting 工程

三、chapter-5-spring-boot-paging-sorting 工程配置详解

四、小结

运行环境:

Mac OS 10.12.x

JDK 8 +

Spring Boot 2.0.0.M4 

一、前言

Spring 2.x 更新了一个小小的功能即:

Spring Data Web configuration

Spring Boot exposes a new spring.data.web configuration namespace that allows to easily configure paging and sorting.

就是说,可以在 application.properties 中自定义分页和排序相关的默认值和参数名。

具体见地址:https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0.0-M2-Release-Notes

二、运行工程

git clone 下载工程 spring-boot-core-book-demo ,项目地址见 GitHub –

https://github.com/JeffLi1993/spring-boot-core-book-demo。

1. 工程结构

项目结构如下图所示:

org.spring.springboot.controller – Controller 层

org.spring.springboot.domain – 实体类及数据操作层 DAO

org.spring.springboot.service – 业务逻辑层

PagingSortingApplication – 应用启动类

application.properties – 应用配置文件,应用启动会自动读取配置

具体详细结构如下:

├── pom.xml

└── src

    ├── main

    │   ├── java

    │   │   └── spring

    │   │       └── boot

    │   │           └── core

    │   │               ├── PagingSortingApplication.java

    │   │               ├── domain

    │   │               │   ├── User.java

    │   │               │   └── UserRepository.java

    │   │               ├── service

    │   │               │   ├── UserService.java

    │   │               │   └── impl

    │   │               │       └── UserServiceImpl.java

    │   │               └── web

    │   │                   └── UserController.java

    │   └── resources

    │       ├── application.properties

    │       └── static

    └── test

2.编译工程

在项目根目录 spring-boot-core-book-demo,运行 maven 指令去编译工程:

mvn clean install

3.运行工程

在 chapter-5-spring-boot-paging-sorting 工程中,右键运行 PagingSortingApplication 应用启动类的 main 函数。待控制台日志中看到启动成功后。

在 PostMan 工具中,新增用户几个:

POST http://localhost:808

  • 19
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

TonyBrown148

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值