master 077329583043 cached
312 files
312.8 KB
93.8k tokens
901 symbols
1 requests
Download .txt
Showing preview only (409K chars total). Download the full file or copy to clipboard to get everything.
Repository: JeffLi1993/springboot-learning-example
Branch: master
Commit: 077329583043
Files: 312
Total size: 312.8 KB

Directory structure:
gitextract_8i_wvbh2/

├── .gitignore
├── 2-x-spring-boot-groovy/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── filter/
│           │               │   └── RouteRuleFilter.java
│           │               └── web/
│           │                   └── GroovyScriptController.java
│           └── resources/
│               └── application.properties
├── 2-x-spring-boot-webflux-handling-errors/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── error/
│           │               │   ├── GlobalErrorAttributes.java
│           │               │   ├── GlobalErrorWebExceptionHandler.java
│           │               │   └── GlobalException.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── router/
│           │                   └── CityRouter.java
│           └── resources/
│               └── application.properties
├── LICENSE
├── README.md
├── chapter-1-spring-boot-quickstart/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── demo/
│       │   │       └── springboot/
│       │   │           ├── QuickStartApplication.java
│       │   │           └── web/
│       │   │               ├── HelloBookController.java
│       │   │               └── HelloController.java
│       │   └── resources/
│       │       └── application.properties
│       └── test/
│           ├── java/
│           │   └── demo/
│           │       └── springboot/
│           │           └── QuickStartApplicationTests.java
│           └── resources/
│               └── application.properties
├── chapter-2-spring-boot-config/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── demo/
│       │   │       └── springboot/
│       │   │           ├── ConfigApplication.java
│       │   │           ├── config/
│       │   │           │   ├── BookComponent.java
│       │   │           │   └── BookProperties.java
│       │   │           └── web/
│       │   │               └── HelloBookController.java
│       │   └── resources/
│       │       ├── application-dev.properties
│       │       ├── application-prod.properties
│       │       ├── application.properties
│       │       └── application.yml
│       └── test/
│           └── java/
│               └── demo/
│                   └── springboot/
│                       └── ConfigApplicationTests.java
├── chapter-3-spring-boot-web/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── demo/
│       │   │       └── springboot/
│       │   │           ├── WebApplication.java
│       │   │           ├── domain/
│       │   │           │   └── Book.java
│       │   │           ├── service/
│       │   │           │   ├── BookService.java
│       │   │           │   └── impl/
│       │   │           │       └── BookServiceImpl.java
│       │   │           └── web/
│       │   │               └── BookController.java
│       │   └── resources/
│       │       └── application.properties
│       └── test/
│           ├── java/
│           │   └── demo/
│           │       └── springboot/
│           │           ├── WebApplicationTests.java
│           │           └── web/
│           │               └── BookControllerTest.java
│           └── resources/
│               └── application.properties
├── chapter-4-spring-boot-validating-form-input/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── spring/
│       │   │       └── boot/
│       │   │           └── core/
│       │   │               ├── ValidatingFormInputApplication.java
│       │   │               ├── domain/
│       │   │               │   ├── User.java
│       │   │               │   └── UserRepository.java
│       │   │               ├── service/
│       │   │               │   ├── UserService.java
│       │   │               │   └── impl/
│       │   │               │       └── UserServiceImpl.java
│       │   │               └── web/
│       │   │                   └── UserController.java
│       │   └── resources/
│       │       ├── application.properties
│       │       ├── static/
│       │       │   └── css/
│       │       │       └── default.css
│       │       └── templates/
│       │           ├── userForm.html
│       │           └── userList.html
│       └── test/
│           ├── java/
│           │   └── spring/
│           │       └── boot/
│           │           └── core/
│           │               ├── ValidatingFormInputApplicationTests.java
│           │               └── web/
│           │                   └── UserControllerTest.java
│           └── resources/
│               ├── application.properties
│               ├── static/
│               │   └── css/
│               │       └── default.css
│               └── templates/
│                   ├── userForm.html
│                   └── userList.html
├── chapter-4-spring-boot-web-thymeleaf/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── demo/
│       │   │       └── springboot/
│       │   │           ├── WebApplication.java
│       │   │           ├── domain/
│       │   │           │   └── Book.java
│       │   │           ├── service/
│       │   │           │   ├── BookService.java
│       │   │           │   └── impl/
│       │   │           │       └── BookServiceImpl.java
│       │   │           └── web/
│       │   │               └── BookController.java
│       │   └── resources/
│       │       ├── application.properties
│       │       ├── static/
│       │       │   └── css/
│       │       │       └── default.css
│       │       └── templates/
│       │           ├── bookForm.html
│       │           └── bookList.html
│       └── test/
│           └── java/
│               └── demo/
│                   └── springboot/
│                       └── WebApplicationTests.java
├── chapter-5-spring-boot-data-jpa/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── demo/
│       │   │       └── springboot/
│       │   │           ├── WebApplication.java
│       │   │           ├── domain/
│       │   │           │   ├── Book.java
│       │   │           │   └── BookRepository.java
│       │   │           ├── service/
│       │   │           │   ├── BookService.java
│       │   │           │   └── impl/
│       │   │           │       └── BookServiceImpl.java
│       │   │           └── web/
│       │   │               └── BookController.java
│       │   └── resources/
│       │       ├── application.properties
│       │       ├── static/
│       │       │   └── css/
│       │       │       └── default.css
│       │       └── templates/
│       │           ├── bookForm.html
│       │           └── bookList.html
│       └── test/
│           └── java/
│               └── demo/
│                   └── springboot/
│                       └── WebApplicationTests.java
├── chapter-5-spring-boot-paging-sorting/
│   ├── 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
│       └── test/
│           └── java/
│               └── spring/
│                   └── boot/
│                       └── core/
│                           └── PagingSortingApplicationTests.java
├── pom.xml
├── spring-data-elasticsearch-crud/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── repository/
│           │               │   └── CityRepository.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityESServiceImpl.java
│           └── resources/
│               └── application.properties
├── spring-data-elasticsearch-query/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── repository/
│           │               │   └── CityRepository.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityESServiceImpl.java
│           └── resources/
│               └── application.properties
├── springboot-configuration/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   └── java/
│       │       └── org/
│       │           └── spring/
│       │               └── springboot/
│       │                   ├── Application.java
│       │                   └── config/
│       │                       └── MessageConfiguration.java
│       └── test/
│           └── java/
│               └── org/
│                   └── spring/
│                       └── springboot/
│                           └── config/
│                               └── MessageConfigurationTest.java
├── springboot-dubbo-client/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── ClientApplication.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── dubbo/
│           │                   ├── CityDubboConsumerService.java
│           │                   └── CityDubboService.java
│           └── resources/
│               └── application.properties
├── springboot-dubbo-server/
│   ├── DubboProperties.md
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── ServerApplication.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── dubbo/
│           │                   ├── CityDubboService.java
│           │                   └── impl/
│           │                       └── CityDubboServiceImpl.java
│           └── resources/
│               └── application.properties
├── springboot-elasticsearch/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── repository/
│           │               │   └── CityRepository.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityESServiceImpl.java
│           └── resources/
│               └── application.properties
├── springboot-freemarker/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityController.java
│           │               ├── dao/
│           │               │   └── CityDao.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityServiceImpl.java
│           └── resources/
│               ├── application.properties
│               ├── mapper/
│               │   └── CityMapper.xml
│               └── web/
│                   ├── city.ftl
│                   └── cityList.ftl
├── springboot-hbase/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── dao/
│           │               │   └── CityRowMapper.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityServiceImpl.java
│           └── resources/
│               └── application.properties
├── springboot-helloworld/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   └── java/
│       │       └── org/
│       │           └── spring/
│       │               └── springboot/
│       │                   ├── Application.java
│       │                   └── web/
│       │                       └── HelloWorldController.java
│       └── test/
│           └── java/
│               └── org/
│                   └── spring/
│                       └── springboot/
│                           └── web/
│                               └── HelloWorldControllerTest.java
├── springboot-mybatis/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── dao/
│           │               │   └── CityDao.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityServiceImpl.java
│           └── resources/
│               ├── application.properties
│               └── mapper/
│                   └── CityMapper.xml
├── springboot-mybatis-annotation/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── dao/
│           │               │   └── CityDao.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityServiceImpl.java
│           └── resources/
│               └── application.properties
├── springboot-mybatis-mutil-datasource/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── config/
│           │               │   └── ds/
│           │               │       ├── ClusterDataSourceConfig.java
│           │               │       └── MasterDataSourceConfig.java
│           │               ├── controller/
│           │               │   └── UserRestController.java
│           │               ├── dao/
│           │               │   ├── cluster/
│           │               │   │   └── CityDao.java
│           │               │   └── master/
│           │               │       └── UserDao.java
│           │               ├── domain/
│           │               │   ├── City.java
│           │               │   └── User.java
│           │               └── service/
│           │                   ├── UserService.java
│           │                   └── impl/
│           │                       └── UserServiceImpl.java
│           └── resources/
│               ├── application.properties
│               └── mapper/
│                   ├── cluster/
│                   │   └── CityMapper.xml
│                   └── master/
│                       └── UserMapper.xml
├── springboot-mybatis-redis/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── dao/
│           │               │   └── CityDao.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityServiceImpl.java
│           └── resources/
│               ├── application.properties
│               └── mapper/
│                   └── CityMapper.xml
├── springboot-mybatis-redis-annotation/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── org/
│       │   │       └── spring/
│       │   │           └── springboot/
│       │   │               ├── Application.java
│       │   │               ├── domain/
│       │   │               │   └── City.java
│       │   │               └── service/
│       │   │                   ├── CityService.java
│       │   │                   └── impl/
│       │   │                       └── CityServiceImpl.java
│       │   └── resources/
│       │       └── application.properties
│       └── test/
│           └── org/
│               └── spring/
│                   └── springboot/
│                       └── ApplicationTests.java
├── springboot-properties/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── org/
│       │   │       └── spring/
│       │   │           └── springboot/
│       │   │               ├── Application.java
│       │   │               ├── property/
│       │   │               │   ├── HomeProperties.java
│       │   │               │   └── UserProperties.java
│       │   │               └── web/
│       │   │                   └── HelloWorldController.java
│       │   └── resources/
│       │       ├── application-dev.properties
│       │       ├── application-prod.properties
│       │       └── application.properties
│       └── test/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── property/
│           │               │   ├── HomeProperties1.java
│           │               │   └── PropertiesTest.java
│           │               └── web/
│           │                   └── HelloWorldControllerTest.java
│           └── resouorces/
│               └── application.yml
├── springboot-restful/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── dao/
│           │               │   └── CityDao.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityServiceImpl.java
│           └── resources/
│               ├── application.properties
│               └── mapper/
│                   └── CityMapper.xml
├── springboot-validation-over-json/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   └── java/
│       │       └── org/
│       │           └── spring/
│       │               └── springboot/
│       │                   ├── Application.java
│       │                   ├── constant/
│       │                   │   └── CityErrorInfoEnum.java
│       │                   ├── result/
│       │                   │   ├── ErrorInfoInterface.java
│       │                   │   ├── GlobalErrorInfoEnum.java
│       │                   │   ├── GlobalErrorInfoException.java
│       │                   │   ├── GlobalErrorInfoHandler.java
│       │                   │   └── ResultBody.java
│       │                   └── web/
│       │                       ├── City.java
│       │                       └── ErrorJsonController.java
│       └── test/
│           └── java/
│               └── org/
│                   └── spring/
│                       └── springboot/
│                           └── web/
│                               └── ErrorJsonControllerTest.java
├── springboot-webflux-1-quickstart/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── router/
│           │                   └── CityRouter.java
│           └── resources/
│               └── application.properties
├── springboot-webflux-10-book-manage-sys/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── demo/
│           │       └── springboot/
│           │           ├── WebApplication.java
│           │           ├── dao/
│           │           │   └── CityRepository.java
│           │           ├── domain/
│           │           │   └── City.java
│           │           ├── service/
│           │           │   ├── CityService.java
│           │           │   └── impl/
│           │           │       └── CityServiceImpl.java
│           │           └── web/
│           │               └── CityController.java
│           └── resources/
│               ├── application.properties
│               ├── static/
│               │   └── css/
│               │       └── default.css
│               └── templates/
│                   ├── cityForm.html
│                   └── cityList.html
├── springboot-webflux-2-restful/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── dao/
│           │               │   └── CityRepository.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── webflux/
│           │                   └── controller/
│           │                       └── CityWebFluxController.java
│           └── resources/
│               └── application.properties
├── springboot-webflux-3-mongodb/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── dao/
│           │               │   └── CityRepository.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── webflux/
│           │                   └── controller/
│           │                       └── CityWebFluxController.java
│           └── resources/
│               └── application.properties
├── springboot-webflux-4-thymeleaf/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── dao/
│           │               │   └── CityRepository.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── webflux/
│           │                   └── controller/
│           │                       └── CityWebFluxController.java
│           └── resources/
│               ├── application.properties
│               └── templates/
│                   ├── cityList.html
│                   └── hello.html
├── springboot-webflux-5-thymeleaf-mongodb/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── dao/
│           │               │   └── CityRepository.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── webflux/
│           │                   └── controller/
│           │                       └── CityWebFluxController.java
│           └── resources/
│               ├── application.properties
│               └── templates/
│                   ├── city.html
│                   └── cityList.html
├── springboot-webflux-6-redis/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── webflux/
│           │                   └── controller/
│           │                       ├── CityWebFluxController.java
│           │                       └── CityWebFluxReactiveController.java
│           └── resources/
│               └── application.properties
├── springboot-webflux-7-redis-cache/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── dao/
│           │               │   └── CityRepository.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── webflux/
│           │                   └── controller/
│           │                       └── CityWebFluxController.java
│           └── resources/
│               └── application.properties
├── springboot-webflux-8-websocket/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── org/
│       │   │       └── spring/
│       │   │           └── springboot/
│       │   │               ├── Application.java
│       │   │               ├── config/
│       │   │               │   └── WebSocketConfiguration.java
│       │   │               └── handler/
│       │   │                   └── EchoHandler.java
│       │   └── resources/
│       │       ├── application.properties
│       │       └── websocket-client.html
│       └── test/
│           └── java/
│               └── WSClient.java
└── springboot-webflux-9-test/
    ├── pom.xml
    └── src/
        ├── main/
        │   ├── java/
        │   │   └── org/
        │   │       └── spring/
        │   │           └── springboot/
        │   │               ├── Application.java
        │   │               ├── dao/
        │   │               │   └── CityRepository.java
        │   │               ├── domain/
        │   │               │   └── City.java
        │   │               ├── handler/
        │   │               │   └── CityHandler.java
        │   │               └── webflux/
        │   │                   └── controller/
        │   │                       └── CityWebFluxController.java
        │   └── resources/
        │       └── application.properties
        └── test/
            └── java/
                └── org/
                    └── spring/
                        └── springboot/
                            └── handler/
                                └── CityHandlerTest.java

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*


target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/

================================================
FILE: 2-x-spring-boot-groovy/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>springboot</groupId>
  <artifactId>2-x-spring-boot-groovy</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>2-x-spring-boot-groovy</name>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.6.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy</artifactId>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

</project>


================================================
FILE: 2-x-spring-boot-groovy/src/main/java/org/spring/springboot/Application.java
================================================
package org.spring.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 */
// Spring Boot 应用的标识
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        // 程序启动入口
        // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件
        SpringApplication.run(Application.class,args);

    }
}


================================================
FILE: 2-x-spring-boot-groovy/src/main/java/org/spring/springboot/filter/RouteRuleFilter.java
================================================
package org.spring.springboot.filter;

import groovy.lang.Binding;
import groovy.lang.GroovyShell;
import groovy.lang.Script;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class RouteRuleFilter {
    
    public Map<String,Object> filter(Map<String,Object> input) {
    
        Binding binding = new Binding();
        binding.setVariable("input", input);
    
        GroovyShell shell = new GroovyShell(binding);
        
        String filterScript = "def field = input.get('field')\n"
                                      + "if (input.field == 'buyer') { return ['losDataBusinessName':'losESDataBusiness3', 'esIndex':'potential_goods_recommend1']}\n"
                                      + "if (input.field == 'seller') { return ['losDataBusinessName':'losESDataBusiness4', 'esIndex':'potential_goods_recommend2']}\n";
        Script script = shell.parse(filterScript);
        Object ret = script.run();
        System.out.println(ret);
        return (Map<String, Object>) ret;
    }
}


================================================
FILE: 2-x-spring-boot-groovy/src/main/java/org/spring/springboot/web/GroovyScriptController.java
================================================
package org.spring.springboot.web;

import org.spring.springboot.filter.RouteRuleFilter;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/groovy/script")
public class GroovyScriptController {

    @RequestMapping(value = "/filter", method = RequestMethod.GET)
    public String filter() {
        
        RouteRuleFilter routeRuleFilter = new RouteRuleFilter();
    
        Map<String, Object> input = new HashMap<>();
        input.put("field", "seller");
    
        Map<String, Object> output = routeRuleFilter.filter(input);
        return "true";
        
    }
    
    public static void main(String[] args) {
        GroovyScriptController groovyScriptController = new GroovyScriptController();
        groovyScriptController.filter();
    }
}


================================================
FILE: 2-x-spring-boot-groovy/src/main/resources/application.properties
================================================


================================================
FILE: 2-x-spring-boot-webflux-handling-errors/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>springboot</groupId>
  <artifactId>2-x-spring-boot-webflux-handling-errors</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>2-x-spring-boot-webflux-handling-errors</name>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.3.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-webflux</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.projectreactor</groupId>
      <artifactId>reactor-test</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

</project>


================================================
FILE: 2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/Application.java
================================================
package org.spring.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 */
// Spring Boot 应用的标识
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        // 程序启动入口
        // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件
        SpringApplication.run(Application.class,args);

    }
}


================================================
FILE: 2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/error/GlobalErrorAttributes.java
================================================
package org.spring.springboot.error;

import org.springframework.boot.web.reactive.error.DefaultErrorAttributes;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.ServerRequest;

import java.util.Map;

@Component
public class GlobalErrorAttributes extends DefaultErrorAttributes {
    
    @Override
    public Map<String, Object> getErrorAttributes(ServerRequest request, boolean includeStackTrace) {
        Map<String, Object> map = super.getErrorAttributes(request, includeStackTrace);
    
        if (getError(request) instanceof GlobalException) {
            GlobalException ex = (GlobalException) getError(request);
            map.put("exception", ex.getClass().getSimpleName());
            map.put("message", ex.getMessage());
            map.put("status", ex.getStatus().value());
            map.put("error", ex.getStatus().getReasonPhrase());
            
            return map;
        }
    
        map.put("exception", "SystemException");
        map.put("message", "System Error , Check logs!");
        map.put("status", "500");
        map.put("error", " System Error ");
        return map;
    }
}


================================================
FILE: 2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/error/GlobalErrorWebExceptionHandler.java
================================================
package org.spring.springboot.error;

import org.springframework.boot.autoconfigure.web.ResourceProperties;
import org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler;
import org.springframework.boot.web.reactive.error.ErrorAttributes;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import java.util.Map;

@Component
@Order(-2)
public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler {

    public GlobalErrorWebExceptionHandler(GlobalErrorAttributes g, ApplicationContext applicationContext,
            ServerCodecConfigurer serverCodecConfigurer) {
        super(g, new ResourceProperties(), applicationContext);
        super.setMessageWriters(serverCodecConfigurer.getWriters());
        super.setMessageReaders(serverCodecConfigurer.getReaders());
    }

    @Override
    protected RouterFunction<ServerResponse> getRoutingFunction(final ErrorAttributes errorAttributes) {
        return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse);
    }

    private Mono<ServerResponse> renderErrorResponse(final ServerRequest request) {

        final Map<String, Object> errorPropertiesMap = getErrorAttributes(request, false);

        return ServerResponse.status(HttpStatus.BAD_REQUEST)
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .body(BodyInserters.fromObject(errorPropertiesMap));
    }

}


================================================
FILE: 2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/error/GlobalException.java
================================================
package org.spring.springboot.error;

import org.springframework.http.HttpStatus;
import org.springframework.web.server.ResponseStatusException;

public class GlobalException extends ResponseStatusException {
    
    public GlobalException(HttpStatus status, String message) {
        super(status, message);
    }
    
    public GlobalException(HttpStatus status, String message, Throwable e) {
        super(status, message, e);
    }
}


================================================
FILE: 2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/handler/CityHandler.java
================================================
package org.spring.springboot.handler;

import org.spring.springboot.error.GlobalException;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import java.util.Optional;

@Component
public class CityHandler {
    
    public Mono<ServerResponse> helloCity(ServerRequest request) {
        return ServerResponse.ok().body(sayHelloCity(request), String.class);
    }
    
    private Mono<String> sayHelloCity(ServerRequest request) {
        Optional<String> cityParamOptional = request.queryParam("city");
        if (!cityParamOptional.isPresent()) {
            throw new GlobalException(HttpStatus.INTERNAL_SERVER_ERROR, "request param city is ERROR");
        }
        
        return Mono.just("Hello," + cityParamOptional.get());
    }
}


================================================
FILE: 2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/router/CityRouter.java
================================================
package org.spring.springboot.router;

import org.spring.springboot.handler.CityHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

@Configuration
public class CityRouter {
    
    @Bean
    public RouterFunction<ServerResponse> routeCity(CityHandler cityHandler) {
        return RouterFunctions.route(RequestPredicates.GET("/hello").and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), cityHandler::helloCity);
    }
    
}


================================================
FILE: 2-x-spring-boot-webflux-handling-errors/src/main/resources/application.properties
================================================


================================================
FILE: LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "{}"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright {yyyy} {name of copyright owner}

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: README.md
================================================
[![Star History Chart](https://api.star-history.com/svg?repos=JeffLi1993/springboot-learning-example&type=Date)](https://star-history.com/#JeffLi1993/springboot-learning-example&Date)


### 一、支持泥瓦匠

关注泥瓦匠个人博客的更新:[我的博客](https://www.bysocket.com "我的博客") - 分享学习可落地的技术博文

**Spring Boot 2.x 系列教程**,spring boot 实践学习案例,是初学者及核心技术巩固的最佳实践。

1. 拿起微信,关注公众号:「程序员泥瓦匠 」
2. 给教程的开源代码仓库点个 **Star** 吧
	- [GitHub(springboot-learning-example)](https://github.com/JeffLi1993/springboot-learning-example "GitHub(springboot-learning-example)")
	- [Gitee(springboot-learning-example)](https://gitee.com/jeff1993/springboot-learning-example "Gitee(springboot-learning-example)")
3. 帮忙分享该系列文章链接给更多的朋友

### 二、系列文章目录

#### 『 Spring Boot 2 快速教程 』
- [Spring Boot 2 快速教程:WebFlux 集成 Thymeleaf(五)](https://www.bysocket.com/springboot/2358.html)
- [Spring Boot 2 快速教程:WebFlux 集成 Mongodb(四)](https://www.bysocket.com/springboot/2342.html)
- [Spring Boot 2 快速教程:WebFlux Restful CRUD 实践(三)](https://www.bysocket.com/technique/2328.html)
- [Spring Boot 2 快速教程:WebFlux 快速入门(二)](https://www.bysocket.com/technique/2306.html)
- [Spring Boot 2 快速教程:WebFlux REST API 全局异常处理 Error Handling](https://www.bysocket.com/technique/2272.html)
- [Spring Boot 2 快速教程:WebFlux 系列教程大纲(一)](https://www.bysocket.com/technique/2290.html)

#### 『 基础 - 入门篇 』
- [Spring Boot 2.0 配置图文教程](https://www.bysocket.com/technique/2135.html)
- [Spring Boot 2.0 的快速入门(图文教程)](https://www.bysocket.com/technique/2119.html)
- [Spring Boot 之 HelloWorld 详解](http://www.bysocket.com/?p=1124)
-  [Spring Boot 之配置文件详解](http://www.bysocket.com/?p=1786)

#### 『 基础 - Web 业务开发篇 』
- [Spring Boot Web 开发注解篇](http://www.bysocket.com/?p=1929)
- [Spring Boot 表单验证篇](http://www.bysocket.com/?p=1942)
- [Spring Boot 2.x 小新功能 – Spring Data Web configuration](http://www.bysocket.com/?p=1950)
- [Spring Boot 实现 Restful 服务,基于 HTTP / JSON 传输](http://www.bysocket.com/?p=1627)
- [Spring Boot 之 RESRful API 权限控制](http://www.bysocket.com/?p=1080)
- [Spring Boot 集成 FreeMarker](http://www.bysocket.com/?p=1666)
- [Spring Boot HTTP over JSON 的错误码异常处理](http://www.bysocket.com/?p=1692)
- Spring Boot 使用 Swagger2 构建 RESRful API 文档
- Spring Boot 集成 JSP
- Spring Boot 集成 Thymeleaf
- Spring Boot 单元测试的使用
- Spring Boot 热更新部署

#### 『 基础 – 数据存储篇 』
- [Spring Boot 整合 Mybatis 的完整 Web 案例](http://www.bysocket.com/?p=1610)
- [Spring Boot 整合 Mybatis Annotation 注解案例](http://www.bysocket.com/?p=1811)
- [Spring Boot 整合 Mybatis 实现 Druid 多数据源配置](http://www.bysocket.com/?p=1712)
- Spring Boot 整合使用 JdbcTemplate
- Spring Boot 整合 Spring-data-jpa
- Spring Boot 声明式事务管理

#### 『 基础 – 数据缓存篇 』
- [Spring Boot 整合 Redis 实现缓存操作](http://www.bysocket.com/?p=1756)
- Spring Boot 整合 Redis Annotation 实现缓存操作
- Spring Boot 整合 MongoDB 实现缓存操作
- Spring Boot 整合 EhCache 实现缓存操作

#### 『 基础 – 日志管理篇 』
- Spring Boot 默认日志 logback 配置解析
- Spring Boot 使用 log4j 记录日志
- Spring Boot 对 log4j 进行多环境不同日志级别的控制
- Spring Boot 使用 log4j 记录日志到 MongoDB
- Spring Boot 1.5.x 动态修改日志级别
 
#### 『 基础 – 应用篇 』
- Spring Boot Actuator 监控
- Spring Boot Web 应用部署
 
#### 『 提升 – 安全控制及权限篇 』
- Spring Boot 整合 Spring Security
- Spring Boot 整合 Shiro
- Spring Boot 整合 Spring Session
 
#### 『 提升 – 中间件篇 』
- [Spring Boot 2.x :通过 spring-boot-starter-hbase 集成 HBase](https://www.bysocket.com/technique/2162.html)
- Spring Boot 整合 RabbitMQ
- Spring Boot 整合 Quartz

#### 『 提升 – 源码篇 』
- Spring Boot 启动原理解析
 
#### 『 Elasticsearch 篇 』
- [Spring Boot 整合 Elasticsearch](http://www.bysocket.com/?p=1829)
- [深入浅出 spring-data-elasticsearch 之 ElasticSearch 架构初探(一)](http://www.bysocket.com/?p=1889)
- [深入浅出 spring-data-elasticsearch 系列 – 概述及入门(二)](http://www.bysocket.com/?p=1894)
- [深入浅出 spring-data-elasticsearch – 基本案例详解(三)](http://www.bysocket.com/?p=1899)
- [深入浅出 spring-data-elasticsearch – 实战案例详解(四)](http://www.bysocket.com/?p=1902)

#### 『 Dubbo 篇 』
-  [Spring Boot 整合 Dubbo/ZooKeeper 详解 SOA 案例](http://www.bysocket.com/?p=1681)
-  [Spring Boot 中如何使用 Dubbo Activate 扩展点](http://www.bysocket.com/?p=1782)
-  [Spring Boot Dubbo applications.properties 配置清单](http://www.bysocket.com/?p=1805)

### 三、最后推荐

- [我的博客](https://www.bysocket.com "我的博客"):分享学习可落地的技术博文
- [我的GitHub](https://github.com/JeffLi1993 "我的GitHub"):Follow 下呗
- [我的Gitee](https://gitee.com/jeff1993 "我的Gitee"):Follow 下呗
- [Spring问答社区](http://www.spring4all.com/ "Spring问答社区"):如果您有什么问题,可以去这里发帖

### 四、我的公号

<img width="300" src="https://www.bysocket.com/images/qrcode.jpeg">


================================================
FILE: chapter-1-spring-boot-quickstart/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <name>chapter-1-spring-boot-quickstart</name>
    <description>《Spring Boot 2.x 核心技术实战 - 上 基础篇》第 1 章《Spring Boot 入门》Demo</description>

    <groupId>demo.springboot</groupId>
    <artifactId>chapter-1-spring-boot-quickstart</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <!-- Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- 测试依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <!-- Spring Boot Maven 插件 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>


================================================
FILE: chapter-1-spring-boot-quickstart/src/main/java/demo/springboot/QuickStartApplication.java
================================================
package demo.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 * Created by bysocket on 26/09/2017.
 */
@SpringBootApplication
public class QuickStartApplication {
    public static void main(String[] args) {
        SpringApplication.run(QuickStartApplication.class, args);
    }
}


================================================
FILE: chapter-1-spring-boot-quickstart/src/main/java/demo/springboot/web/HelloBookController.java
================================================
package demo.springboot.web;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Spring Boot Hello案例
 *
 * Created by bysocket on 26/09/2017.
 */
@RestController
public class HelloBookController {

    @RequestMapping(value = "/book/hello",method = RequestMethod.GET)
    public String sayHello() {
        return "Hello,《Spring Boot 2.x 核心技术实战 - 上 基础篇》!";
    }
}


================================================
FILE: chapter-1-spring-boot-quickstart/src/main/java/demo/springboot/web/HelloController.java
================================================
package demo.springboot.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Spring Boot Hello案例
 *
 * Created by bysocket on 26/09/2017.
 */
@Controller
public class HelloController {

    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    @ResponseBody
    public String sayHello() {
        return "Hello,Spring Boot!";
    }
}


================================================
FILE: chapter-1-spring-boot-quickstart/src/main/resources/application.properties
================================================
server.port=-1

================================================
FILE: chapter-1-spring-boot-quickstart/src/test/java/demo/springboot/QuickStartApplicationTests.java
================================================
package demo.springboot;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = QuickStartApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application.properties")
public class QuickStartApplicationTests {

    @Autowired
    private MockMvc mvc;


    @Test
    public void requestHello_thenStatus200_and_outputHello() throws Exception {
        mvc.perform(get("/hello")
                .contentType(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk())
                .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_PLAIN))
                .andExpect(content().encoding("UTF-8"))
                .andExpect(content().string("Hello,Spring Boot!"));
    }

}


================================================
FILE: chapter-1-spring-boot-quickstart/src/test/resources/application.properties
================================================
server.port=-1

================================================
FILE: chapter-2-spring-boot-config/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <name>chapter-2-spring-boot-config</name>
    <description>《Spring Boot 2.x 核心技术实战 - 上 基础篇》第 2 章《Spring Boot 配置》Demo</description>

    <groupId>demo.springboot</groupId>
    <artifactId>chapter-2-spring-boot-config</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <!-- Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- 自定义 swagger2 Starter 组件依赖 -->
        <dependency>
            <groupId>com.spring4all</groupId>
            <artifactId>spring-boot-starter-swagger</artifactId>
            <version>1.5.1.RELEASE</version>
        </dependency>

        <!-- 测试依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <!-- Spring Boot Maven 插件 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.1.3.RELEASE</version>
            </plugin>

        </plugins>
    </build>


    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>


================================================
FILE: chapter-2-spring-boot-config/src/main/java/demo/springboot/ConfigApplication.java
================================================
package demo.springboot;

import com.spring4all.swagger.EnableSwagger2Doc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 * Created by bysocket on 26/09/2017.
 */
@EnableSwagger2Doc // 开启 Swagger
@SpringBootApplication
public class ConfigApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConfigApplication.class, args);
    }
}


================================================
FILE: chapter-2-spring-boot-config/src/main/java/demo/springboot/config/BookComponent.java
================================================
package demo.springboot.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * 书属性
 *
 */
@Component
@ConfigurationProperties(prefix = "demo.book")
@Validated
public class BookComponent {

    /**
     * 书名
     */
    @NotEmpty
    private String name;

    /**
     * 作者
     */
    @NotNull
    private String writer;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getWriter() {
        return writer;
    }

    public void setWriter(String writer) {
        this.writer = writer;
    }
}


================================================
FILE: chapter-2-spring-boot-config/src/main/java/demo/springboot/config/BookProperties.java
================================================
package demo.springboot.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 书属性
 *
 * Created by bysocket on 27/09/2017.
 */
@Component
public class BookProperties {

    /**
     * 书名
     */
    @Value("${demo.book.name}")
    private String name;

    /**
     * 作者
     */
    @Value("${demo.book.writer}")
    private String writer;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getWriter() {
        return writer;
    }

    public void setWriter(String writer) {
        this.writer = writer;
    }
}


================================================
FILE: chapter-2-spring-boot-config/src/main/java/demo/springboot/web/HelloBookController.java
================================================
package demo.springboot.web;

import demo.springboot.config.BookProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Spring Boot Hello案例
 *
 * Created by bysocket on 26/09/2017.
 */
@RestController
public class HelloBookController {

    @Autowired
    BookProperties bookProperties;

    @GetMapping("/book/hello")
    public String sayHello() {
        return "Hello, " + bookProperties.getWriter() + " is writing "
                + bookProperties.getName() + " !";
    }
}


================================================
FILE: chapter-2-spring-boot-config/src/main/resources/application-dev.properties
================================================
## \u4E66\u4FE1\u606F
demo.book.name=[Spring Boot 2.x Core Action] From Dev
demo.book.writer=BYSocket


================================================
FILE: chapter-2-spring-boot-config/src/main/resources/application-prod.properties
================================================
## \u4E66\u4FE1\u606F
demo.book.name=[Spring Boot 2.x Core Action] From Prod
demo.book.writer=BYSocket


================================================
FILE: chapter-2-spring-boot-config/src/main/resources/application.properties
================================================
## \u4E66\u4FE1\u606F
demo.book.name=[Spring Boot 2.x Core Action]
demo.book.writer=BYSocket
demo.book.description=${demo.book.writer}'s${demo.book.name}



================================================
FILE: chapter-2-spring-boot-config/src/main/resources/application.yml
================================================
## 书信息
demo:
    book:
        name: 《Spring Boot 2.x 核心技术实战 - 上 基础篇》
        writer: 泥瓦匠BYSocket

================================================
FILE: chapter-2-spring-boot-config/src/test/java/demo/springboot/ConfigApplicationTests.java
================================================
package demo.springboot;

import demo.springboot.config.BookComponent;
import demo.springboot.config.BookProperties;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class ConfigApplicationTests {

	@Autowired
	BookProperties bookProperties;

	@Autowired
	BookComponent bookComponent;

	@Test
	public void testBookProperties() {
		Assert.assertEquals(bookProperties.getName(),"[Spring Boot 2.x Core Action]");
		Assert.assertEquals(bookProperties.getWriter(),"BYSocket");
	}

	@Test
	public void testBookComponent() {
		Assert.assertEquals(bookComponent.getName(),"[Spring Boot 2.x Core Action]");
		Assert.assertEquals(bookComponent.getWriter(),"BYSocket");
	}
}


================================================
FILE: chapter-3-spring-boot-web/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <name>chapter-3-spring-boot-web</name>
    <description>《Spring Boot 2.x 核心技术实战 - 上 基础篇》第 3 章《Web 开发》Demo</description>

    <groupId>demo.springboot</groupId>
    <artifactId>chapter-3-spring-boot-web</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <!-- Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- 测试依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <!-- Spring Boot Maven 插件
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            -->
        </plugins>
    </build>


    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>


================================================
FILE: chapter-3-spring-boot-web/src/main/java/demo/springboot/WebApplication.java
================================================
package demo.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 * Created by bysocket on 26/09/2017.
 */
@SpringBootApplication
public class WebApplication {
    public static void main(String[] args) {
        SpringApplication.run(WebApplication.class, args);
    }
}


================================================
FILE: chapter-3-spring-boot-web/src/main/java/demo/springboot/domain/Book.java
================================================
package demo.springboot.domain;

import java.io.Serializable;

/**
 * Book 实体类
 *
 * Created by bysocket on 27/09/2017.
 */
public class Book implements Serializable {

    /**
     * 编号
     */
    private Long id;

    /**
     * 书名
     */
    private String name;

    /**
     * 作者
     */
    private String writer;

    /**
     * 简介
     */
    private String introduction;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getWriter() {
        return writer;
    }

    public void setWriter(String writer) {
        this.writer = writer;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }

    public Book(Long id, String name, String writer, String introduction) {
        this.id = id;
        this.name = name;
        this.writer = writer;
        this.introduction = introduction;
    }

    public Book(Long id, String name) {
        this.id = id;
        this.name = name;
    }

    public Book(String name) {
        this.name = name;
    }

    public Book() {
    }
}


================================================
FILE: chapter-3-spring-boot-web/src/main/java/demo/springboot/service/BookService.java
================================================
package demo.springboot.service;

import demo.springboot.domain.Book;

import java.util.List;

/**
 * Book 业务接口层
 *
 * Created by bysocket on 27/09/2017.
 */
public interface BookService {
    /**
     * 获取所有 Book
     */
    List<Book> findAll();

    /**
     * 新增 Book
     *
     * @param book {@link Book}
     */
    Book insertByBook(Book book);

    /**
     * 更新 Book
     *
     * @param book {@link Book}
     */
    Book update(Book book);

    /**
     * 删除 Book
     *
     * @param id 编号
     */
    Book delete(Long id);

    /**
     * 获取 Book
     *
     * @param id 编号
     */
    Book findById(Long id);

    /**
     * 查找书是否存在
     * @param book
     * @return
     */
    boolean exists(Book book);

    /**
     * 根据书名获取书籍
     * @param name
     * @return
     */
    Book findByName(String name);
}


================================================
FILE: chapter-3-spring-boot-web/src/main/java/demo/springboot/service/impl/BookServiceImpl.java
================================================
package demo.springboot.service.impl;

import demo.springboot.domain.Book;
import demo.springboot.service.BookService;
import demo.springboot.web.BookController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import javax.annotation.PostConstruct;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

/**
 * Book 业务层实现
 * <p>
 * Created by bysocket on 27/09/2017.
 */
@Service
public class BookServiceImpl implements BookService {

    private static final AtomicLong counter = new AtomicLong();


    /**
     * 使用集合模拟数据库
     */
    private static List<Book> books = new ArrayList<>(
            Arrays.asList(
                    new Book(counter.incrementAndGet(), "book")));


    // 模拟数据库,存储 Book 信息
    // 第五章《数据存储》会替换成 MySQL 存储
    private static Map<String, Book> BOOK_DB = new HashMap<>();

    @Override
    public List<Book> findAll() {
        return new ArrayList<>(BOOK_DB.values());
    }

    @Override
    public Book insertByBook(Book book) {
        book.setId(BOOK_DB.size() + 1L);
        BOOK_DB.put(book.getId().toString(), book);
        return book;
    }

    @Override
    public Book update(Book book) {
        BOOK_DB.put(book.getId().toString(), book);
        return book;
    }

    @Override
    public Book delete(Long id) {
        return BOOK_DB.remove(id.toString());
    }

    @Override
    public Book findById(Long id) {
        return BOOK_DB.get(id.toString());
    }

    @Override
    public boolean exists(Book book) {
        return findByName(book.getName()) != null;
    }

    @Override
    public Book findByName(String name) {

        for (Book book : books) {
            if (book.getName().equals(name)) {
                return book;
            }
        }

        return null;
    }
}


================================================
FILE: chapter-3-spring-boot-web/src/main/java/demo/springboot/web/BookController.java
================================================
package demo.springboot.web;

import demo.springboot.domain.Book;
import demo.springboot.service.BookService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.util.UriComponentsBuilder;

import java.util.List;

/**
 * Book 控制层
 *
 * Created by bysocket on 27/09/2017.
 */
@RestController
@RequestMapping(value = "/book")
public class BookController {


    private final Logger LOG = LoggerFactory.getLogger(BookController.class);


    @Autowired
    BookService bookService;

    /**
     * 获取 Book 列表
     * 处理 "/book" 的 GET 请求,用来获取 Book 列表
     */
    @RequestMapping(method = RequestMethod.GET)
    public List<Book> getBookList() {
        return bookService.findAll();
    }

    /**
     * 获取 Book
     * 处理 "/book/{id}" 的 GET 请求,用来获取 Book 信息
     */
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public Book getBook(@PathVariable Long id) {
        return bookService.findById(id);
    }

    /**
     * 创建 Book
     * 处理 "/book/create" 的 POST 请求,用来新建 Book 信息
     * 通过 @RequestBody 绑定实体参数,也通过 @RequestParam 传递参数
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public ResponseEntity<Void> postBook(@RequestBody Book book, UriComponentsBuilder ucBuilder) {

        LOG.info("creating new book: {}", book);

        if (book.getName().equals("conflict")){
            LOG.info("a book with name " + book.getName() + " already exists");
            return new ResponseEntity<>(HttpStatus.CONFLICT);
        }

        bookService.insertByBook(book);

        HttpHeaders headers = new HttpHeaders();
        headers.setLocation(ucBuilder.path("/book/{id}").buildAndExpand(book.getId()).toUri());
        return new ResponseEntity<>(headers, HttpStatus.CREATED);
    }

    /**
     * 更新 Book
     * 处理 "/update" 的 PUT 请求,用来更新 Book 信息
     */
    @RequestMapping(value = "/update", method = RequestMethod.PUT)
    public Book putBook(@RequestBody Book book) {
        return bookService.update(book);
    }

    /**
     * 删除 Book
     * 处理 "/book/{id}" 的 GET 请求,用来删除 Book 信息
     */
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
    public Book deleteBook(@PathVariable Long id) {
        return bookService.delete(id);
    }

}


================================================
FILE: chapter-3-spring-boot-web/src/main/resources/application.properties
================================================


================================================
FILE: chapter-3-spring-boot-web/src/test/java/demo/springboot/WebApplicationTests.java
================================================
package demo.springboot;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class WebApplicationTests {

	@Test
	public void contextLoads() {
	}

}


================================================
FILE: chapter-3-spring-boot-web/src/test/java/demo/springboot/web/BookControllerTest.java
================================================
package demo.springboot.web;

import com.fasterxml.jackson.databind.ObjectMapper;
import demo.springboot.WebApplication;
import demo.springboot.domain.Book;
import demo.springboot.service.BookService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;


@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = WebApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application.properties")
public class BookControllerTest {

    private MockMvc mockMvc;

    @Mock
    private BookService bookService;

    @InjectMocks
    private BookController bookController;

    @Before
    public void init() {
        MockitoAnnotations.initMocks(this);
        mockMvc = MockMvcBuilders
                .standaloneSetup(bookController)
                //.addFilters(new CORSFilter())
                .build();
    }


    @Test
    public void getBookList() throws Exception {
        mockMvc.perform(get("/book")
                .contentType(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk())
                .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON_UTF8))
                .andExpect(jsonPath("$", hasSize(0)));

    }


    @Test
    public void test_create_book_success() throws Exception {

        Book book = createOneBook();

        when(bookService.insertByBook(book)).thenReturn(book);

        mockMvc.perform(
                post("/book/create")
                        .contentType(MediaType.APPLICATION_JSON)
                        .content(asJsonString(book)))

                .andExpect(status().isCreated())
                .andExpect(header().string("location", containsString("/book/1")));
    }


    @Test
    public void test_create_book_fail_404_not_found() throws Exception {

        Book book = new Book(99L, "conflict");

        when(bookService.exists(book)).thenReturn(true);

        mockMvc.perform(
                post("/book/create")
                        .contentType(MediaType.APPLICATION_JSON)
                        .content(asJsonString(book)))
                .andExpect(status().isConflict());
    }

    @Test
    public void test_get_book_success() throws Exception {

        Book book = new Book(1L, "测试获取一本书", "strongant作者", "社区 www.spring4all.com 出版社出版");

        when(bookService.findById(1L)).thenReturn(book);

        mockMvc.perform(get("/book/{id}", 1L))
                .andExpect(status().isOk())
                .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
                .andExpect(jsonPath("$.id", is(1)))
                .andExpect(jsonPath("$.name", is("测试获取一本书")));

        verify(bookService, times(1)).findById(1L);
        verifyNoMoreInteractions(bookService);
    }

    @Test
    public void test_get_by_id_fail_null_not_found() throws Exception {
        when(bookService.findById(1L)).thenReturn(null);

        //TODO: 查找不到应该抛出 404 状态码, Demo 待优化
        mockMvc.perform(get("/book/{id}", 1L))
                .andExpect(status().isOk())
                .andExpect(content().string(""));

        verify(bookService, times(1)).findById(1L);
        verifyNoMoreInteractions(bookService);
    }

    @Test
    public void test_update_book_success() throws Exception {

        Book book = createOneBook();

        when(bookService.findById(book.getId())).thenReturn(book);
        doReturn(book).when(bookService).update(book);

        mockMvc.perform(
                put("/book/update", book)
                        .contentType(MediaType.APPLICATION_JSON)
                        .content(asJsonString(book)))
                .andExpect(status().isOk());
    }

    @Test
    public void test_update_book_fail_not_found() throws Exception {
        Book book = new Book(999L, "测试书名1");

        when(bookService.findById(book.getId())).thenReturn(null);

        mockMvc.perform(
                put("/book/update", book)
                        .contentType(MediaType.APPLICATION_JSON)
                        .content(asJsonString(book)))
                .andExpect(status().isOk())
                .andExpect(content().string(""));
    }

    // =========================================== Delete Book ============================================

    @Test
    public void test_delete_book_success() throws Exception {

        Book book = new Book(1L, "这本书会被删除啦");

        when(bookService.findById(book.getId())).thenReturn(book);
        doReturn(book).when(bookService).delete(book.getId());

        mockMvc.perform(
                delete("/book/delete/{id}", book.getId())
        ).andExpect(status().isOk());
    }

    @Test
    public void test_delete_book_fail_404_not_found() throws Exception {
        Book book = new Book(1L, "这本书会被删除啦");

        when(bookService.findById(book.getId())).thenReturn(null);

        mockMvc.perform(
                delete("/book/delete/{id}", book.getId()))
                .andExpect(status().isOk());
    }


    public static String asJsonString(final Object obj) {
        try {
            final ObjectMapper mapper = new ObjectMapper();
            return mapper.writeValueAsString(obj);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    private Book createOneBook() {
        Book book = new Book();
        book.setId(1L);
        book.setName("测试书名1");
        book.setIntroduction("这是一本 www.spring4all.com 社区出版的很不错的一本书籍");
        book.setWriter("strongant");
        return book;
    }
}

================================================
FILE: chapter-3-spring-boot-web/src/test/resources/application.properties
================================================
server.port=9090

================================================
FILE: chapter-4-spring-boot-validating-form-input/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>spring.boot.core</groupId>
    <artifactId>chapter-4-spring-boot-validating-form-input</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>chapter-4-spring-boot-validating-form-input</name>
    <description>第四章表单校验案例</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.M4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>

        <!-- Web 依赖 - 包含了 hibernate-validator 依赖-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- 单元测试依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Spring Data JPA 依赖 :: 数据持久层框架 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <!-- h2 数据源连接驱动 -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>

        <!-- 模板引擎 Thymeleaf 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <!-- Spring Boot Maven 插件 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.1.3.RELEASE</version>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/libs-milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>


================================================
FILE: chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/ValidatingFormInputApplication.java
================================================
package spring.boot.core;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import spring.boot.core.domain.User;
import spring.boot.core.domain.UserRepository;

@SpringBootApplication
public class ValidatingFormInputApplication implements CommandLineRunner {


    private Logger LOG = LoggerFactory.getLogger(ValidatingFormInputApplication.class);

    @Autowired
    private UserRepository userRepository;

    public static void main(String[] args) {
        SpringApplication.run(ValidatingFormInputApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        User user1 = new User("Sergey", 24, "1994-01-01");
        User user2 = new User("Ivan", 26, "1994-01-01");
        User user3 = new User("Adam", 31, "1994-01-01");
        LOG.info("Inserting data in DB.");
        userRepository.save(user1);
        userRepository.save(user2);
        userRepository.save(user3);
        LOG.info("User count in DB: {}", userRepository.count());
        LOG.info("User with ID 1: {}", userRepository.findById(1L));
        LOG.info("Deleting user with ID 2L form DB.");
        userRepository.deleteById(2L);
        LOG.info("User count in DB: {}", userRepository.count());
    }
}


================================================
FILE: chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/domain/User.java
================================================
package spring.boot.core.domain;

import org.hibernate.validator.constraints.NotEmpty;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * 用户实体类
 * <p>
 * Created by bysocket on 21/07/2017.
 */
@Entity
public class User implements Serializable {

    /**
     * 编号
     */
    @Id
    @GeneratedValue
    private Long id;

    /**
     * 名称
     */
    @NotEmpty(message = "姓名不能为空")
    @Size(min = 2, max = 8, message = "姓名长度必须大于 2 且小于 20 字")
    private String name;

    /**
     * 年龄
     */
    @NotNull(message = "年龄不能为空")
    @Min(value = 0, message = "年龄大于 0")
    @Max(value = 300, message = "年龄不大于 300")
    private Integer age;

    /**
     * 出生时间
     */
    @NotEmpty(message = "出生时间不能为空")
    private String birthday;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }


    public User(String name, Integer age, String birthday) {
        this.name = name;
        this.age = age;
        this.birthday = birthday;
    }

    public User() {}

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", birthday=" + birthday +
                '}';
    }
}


================================================
FILE: chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/domain/UserRepository.java
================================================
package spring.boot.core.domain;

import org.springframework.data.jpa.repository.JpaRepository;

/**
 * 用户持久层操作接口
 *
 * Created by bysocket on 21/07/2017.
 */
public interface UserRepository extends JpaRepository<User, Long> {

}


================================================
FILE: chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/service/UserService.java
================================================
package spring.boot.core.service;


import spring.boot.core.domain.User;

import java.util.List;

/**
 * User 业务层接口
 *
 * Created by bysocket on 24/07/2017.
 */
public interface UserService {

    List<User> findAll();

    User insertByUser(User user);

    User update(User user);

    User delete(Long id);

    User findById(Long id);
}


================================================
FILE: chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/service/impl/UserServiceImpl.java
================================================
package spring.boot.core.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import spring.boot.core.domain.User;
import spring.boot.core.domain.UserRepository;
import spring.boot.core.service.UserService;

import java.util.List;

/**
 * User 业务层实现
 *
 * Created by bysocket on 24/07/2017.
 */
@Service
public class UserServiceImpl implements UserService {

    private static final Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    UserRepository userRepository;

    @Override
    public List<User> findAll() {
        return userRepository.findAll();
    }

    @Override
    public User insertByUser(User user) {
        LOGGER.info("新增用户:" + user.toString());
        return userRepository.save(user);
    }

    @Override
    public User update(User user) {
        LOGGER.info("更新用户:" + user.toString());
        return userRepository.save(user);
    }

    @Override
    public User delete(Long id) {
        User user = userRepository.findById(id).get();
        userRepository.delete(user);

        LOGGER.info("删除用户:" + user.toString());
        return user;
    }

    @Override
    public User findById(Long id) {
        LOGGER.info("获取用户 ID :" + id);
        return userRepository.findById(id).get();
    }
}


================================================
FILE: chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/web/UserController.java
================================================
package spring.boot.core.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import spring.boot.core.domain.User;
import spring.boot.core.service.UserService;

import javax.validation.Valid;

/**
 * 用户控制层
 *
 * Created by bysocket on 24/07/2017.
 */
@Controller
@RequestMapping(value = "/users")     // 通过这里配置使下面的映射都在 /users
public class UserController {

    @Autowired
    UserService userService;          // 用户服务层

    /**
     *  获取用户列表
     *    处理 "/users" 的 GET 请求,用来获取用户列表
     *    通过 @RequestParam 传递参数,进一步实现条件查询或者分页查询
     */
    @RequestMapping(method = RequestMethod.GET)
    public String getUserList(ModelMap map) {
        map.addAttribute("userList", userService.findAll());
        return "userList";
    }

    /**
     * 显示创建用户表单
     *
     * @param map
     * @return
     */
    @RequestMapping(value = "/create", method = RequestMethod.GET)
    public String createUserForm(ModelMap map) {
        map.addAttribute("user", new User());
        map.addAttribute("action", "create");
        return "userForm";
    }

    /**
     *  创建用户
     *    处理 "/users" 的 POST 请求,用来获取用户列表
     *    通过 @ModelAttribute 绑定参数,也通过 @RequestParam 从页面中传递参数
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public String postUser(ModelMap map,
                           @ModelAttribute @Valid User user,
                           BindingResult bindingResult) {

        if (bindingResult.hasErrors()) {
            map.addAttribute("action", "create");
            return "userForm";
        }

        userService.insertByUser(user);

        return "redirect:/users/";
    }


    /**
     * 显示需要更新用户表单
     *    处理 "/users/{id}" 的 GET 请求,通过 URL 中的 id 值获取 User 信息
     *    URL 中的 id ,通过 @PathVariable 绑定参数
     */
    @RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
    public String getUser(@PathVariable Long id, ModelMap map) {
        map.addAttribute("user", userService.findById(id));
        map.addAttribute("action", "update");
        return "userForm";
    }

    /**
     * 处理 "/users/{id}" 的 PUT 请求,用来更新 User 信息
     *
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public String putUser(ModelMap map,
                          @ModelAttribute @Valid User user,
                          BindingResult bindingResult) {

        if (bindingResult.hasErrors()) {
            map.addAttribute("action", "update");
            return "userForm";
        }

        userService.update(user);
        return "redirect:/users/";
    }

    /**
     * 处理 "/users/{id}" 的 GET 请求,用来删除 User 信息
     */
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
    public String deleteUser(@PathVariable Long id) {

        userService.delete(id);
        return "redirect:/users/";
    }
}

================================================
FILE: chapter-4-spring-boot-validating-form-input/src/main/resources/application.properties
================================================
## 开启 H2 数据库
spring.h2.console.enabled=true

## 配置 H2 数据库连接信息
spring.datasource.url=jdbc:h2:mem:testdb  
spring.datasource.driverClassName=org.h2.Driver  
spring.datasource.username=sa  
spring.datasource.password=



## 是否显示 SQL 语句
spring.jpa.show-sql=true
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.hbm2ddl.auto=create


================================================
FILE: chapter-4-spring-boot-validating-form-input/src/main/resources/static/css/default.css
================================================
/* contentDiv */
.contentDiv {padding:20px 60px;}

================================================
FILE: chapter-4-spring-boot-validating-form-input/src/main/resources/templates/userForm.html
================================================
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <script type="text/javascript" th:src="@{https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js}"></script>
        <link th:href="@{https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css}" rel="stylesheet"/>
        <link th:href="@{/css/default.css}" rel="stylesheet"/>
        <link rel="icon" th:href="@{/images/favicon.ico}" type="image/x-icon"/>
        <meta charset="UTF-8"/>
        <title>用户管理</title>
    </head>

    <body>
        <div class="contentDiv">

            <h5> 《 Spring Boot 2.x 核心技术实战》第二章快速入门案例</h5>

            <legend>
                <strong>用户管理</strong>
            </legend>

            <form th:action="@{/users/{action}(action=${action})}" method="post" class="form-horizontal">

                <input type="hidden" name="id" th:value="${user.id}"/>

                <div class="form-group">
                    <label for="user_name" class="col-sm-2 control-label">名称:</label>
                    <div class="col-xs-4">
                        <input type="text" class="form-control" id="user_name" name="name" th:value="${user.name}" th:field="*{user.name}" />
                    </div>
                    <label class="col-sm-2 control-label text-danger" th:if="${#fields.hasErrors('user.name')}" th:errors="*{user.name}">姓名有误!</label>
                </div>

                <div class="form-group">
                    <label for="user_age" class="col-sm-2 control-label">年龄:</label>
                    <div class="col-xs-4">
                        <input type="text" class="form-control" id="user_age" name="age" th:value="${user.age}" th:field="*{user.age}" />
                    </div>
                    <label class="col-sm-2 control-label text-danger" th:if="${#fields.hasErrors('user.age')}" th:errors="*{user.age}">年龄有误!</label>
                </div>

                <div class="form-group">
                    <label for="user_birthday" class="col-sm-2 control-label">出生日期:</label>
                    <div class="col-xs-4">
                        <input type="date" class="form-control" id="user_birthday" name="birthday" th:value="${user.birthday}" th:field="*{user.birthday}"/>
                    </div>
                    <label class="col-sm-2 control-label text-danger" th:if="${#fields.hasErrors('user.birthday')}" th:errors="*{user.birthday}">生日有误!</label>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <input class="btn btn-primary" type="submit" value="提交"/>&nbsp;&nbsp;
                        <input class="btn" type="button" value="返回" onclick="history.back()"/>
                    </div>
                </div>
            </form>
        </div>
    </body>
</html>

================================================
FILE: chapter-4-spring-boot-validating-form-input/src/main/resources/templates/userList.html
================================================
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <script type="text/javascript" th:src="@{https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js}"></script>
        <link th:href="@{https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css}" rel="stylesheet"/>
        <link th:href="@{/css/default.css}" rel="stylesheet"/>
        <link rel="icon" th:href="@{/images/favicon.ico}" type="image/x-icon"/>
        <meta charset="UTF-8"/>
        <title>用户列表</title>
    </head>

    <body>

        <div class="contentDiv">

            <h5> 《 Spring Boot 2.x 核心技术实战》第二章快速入门案例</h5>

            <table class="table table-hover table-condensed">
                <legend>
                    <strong>用户列表</strong>
                </legend>
                <thead>
                    <tr>
                        <th>用户编号</th>
                        <th>名称</th>
                        <th>年龄</th>
                        <th>出生时间</th>
                        <th>管理</th>
                    </tr>
                </thead>
                <tbody>
                    <tr th:each="user : ${userList}">
                        <th scope="row" th:text="${user.id}"></th>
                        <td><a th:href="@{/users/update/{userId}(userId=${user.id})}" th:text="${user.name}"></a></td>
                        <td th:text="${user.age}"></td>
                        <td th:text="${user.birthday}"></td>
                        <td><a class="btn btn-danger" th:href="@{/users/delete/{userId}(userId=${user.id})}">删除</a></td>
                    </tr>
                </tbody>
            </table>

            <div><a class="btn btn-primary" href="/users/create" role="button">创建用户</a></div>
        </div>

    </body>
</html>

================================================
FILE: chapter-4-spring-boot-validating-form-input/src/test/java/spring/boot/core/ValidatingFormInputApplicationTests.java
================================================
package spring.boot.core;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class ValidatingFormInputApplicationTests {

	@Test
	public void contextLoads() {
	}

}


================================================
FILE: chapter-4-spring-boot-validating-form-input/src/test/java/spring/boot/core/web/UserControllerTest.java
================================================
package spring.boot.core.web;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import spring.boot.core.ValidatingFormInputApplication;
import spring.boot.core.domain.User;
import spring.boot.core.service.UserService;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;

import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.beans.HasPropertyWithValue.hasProperty;
import static org.junit.Assert.assertEquals;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = ValidatingFormInputApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application.properties")
public class UserControllerTest {


    @Autowired
    private MockMvc mockMvc;

    @Autowired
    private UserService userService;

    @Autowired
    private ObjectMapper objectMapper;

    @Test
    public void getUserList() throws Exception {
        mockMvc.perform(get("/users"))
                .andExpect(view().name("userList"))
                .andExpect(status().isOk())
                .andDo(print());
    }

    private User createUser() {
        User user = new User();
        user.setName("测试用户");
        user.setAge(100);
        user.setBirthday("1994-01-01");
        return userService.insertByUser(user);
    }

    @Test
    public void createUserForm() throws Exception {

        mockMvc.perform(get("/users/create"))
                .andDo(print())
                .andExpect(view().name("userForm"))
                .andExpect(request().attribute("action", "create"))
                .andDo(print())
                .andReturn();
    }

    @Test
    public void postUser() throws Exception {
        User user = createUser();
        assertNotNull(user);

        MultiValueMap parameters = new LinkedMultiValueMap<String, String>();
        Map<String, String> maps = objectMapper.convertValue(user, new TypeReference<Map<String, String>>() {
        });
        parameters.setAll(maps);

        mockMvc.perform(post("/users/create").params(parameters))
                .andDo(print())
                .andExpect(status().is(HttpServletResponse.SC_FOUND))
                .andDo(print())
                .andExpect(view().name("redirect:/users/"))
                .andDo(print())
                .andReturn();
    }

    @Test
    public void getUser() throws Exception {

        MvcResult result= mockMvc.perform(get("/users/update/{id}/", 1))
                .andExpect(status().isOk())
                .andExpect(view().name("userForm"))
                .andExpect(MockMvcResultMatchers.model().attributeExists("action"))
                .andExpect(model().attribute("user", hasProperty("id", is(1L))))
                .andExpect(model().attribute("user", hasProperty("name", is("Sergey"))))
                .andExpect(model().attribute("user", hasProperty("age", is(24))))
                .andExpect(model().attribute("user", hasProperty("birthday", is("1994-01-01"))))
                .andReturn();


        MockHttpServletResponse mockResponse=result.getResponse();
        assertThat(mockResponse.getContentType()).isEqualTo("text/html;charset=UTF-8");

        Collection<String> responseHeaders = mockResponse.getHeaderNames();
        assertNotNull(responseHeaders);
        assertEquals(2, responseHeaders.size());
        assertEquals("Check for Content-Type header", "Accept-Language", responseHeaders.iterator().next());
        String responseAsString=mockResponse.getContentAsString();
        assertTrue(responseAsString.contains("用户管理"));
    }

    @Test
    public void putUser() throws Exception {
        User user = createUser();
        assertNotNull(user);

        MultiValueMap parameters = new LinkedMultiValueMap<String, String>();
        Map<String, String> maps = objectMapper.convertValue(user, new TypeReference<Map<String, String>>() {
        });
        parameters.setAll(maps);

        mockMvc.perform(post("/users/update").params(parameters))
                .andDo(print())
                .andExpect(status().is(HttpServletResponse.SC_FOUND))
                .andDo(print())
                .andExpect(view().name("redirect:/users/"))
                .andDo(print())
                .andReturn();
    }

    @Test
    public void deleteUser() throws Exception {
        mockMvc.perform( MockMvcRequestBuilders.delete("/users/delete/{id}", 1L) )
                .andDo(print())
                .andExpect(status().is(HttpServletResponse.SC_FOUND))
                .andExpect(view().name("redirect:/users/"));
    }

    public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        return mapper.writeValueAsBytes(object);
    }
}

================================================
FILE: chapter-4-spring-boot-validating-form-input/src/test/resources/application.properties
================================================
## 开启 H2 数据库
spring.h2.console.enabled=true

## 配置 H2 数据库连接信息
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=


## 是否显示 SQL 语句
spring.jpa.show-sql=true
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.hbm2ddl.auto=create


================================================
FILE: chapter-4-spring-boot-validating-form-input/src/test/resources/static/css/default.css
================================================
/* contentDiv */
.contentDiv {padding:20px 60px;}

================================================
FILE: chapter-4-spring-boot-validating-form-input/src/test/resources/templates/userForm.html
================================================
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <script type="text/javascript" th:src="@{https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js}"></script>
        <link th:href="@{https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css}" rel="stylesheet"/>
        <link th:href="@{/css/default.css}" rel="stylesheet"/>
        <link rel="icon" th:href="@{/images/favicon.ico}" type="image/x-icon"/>
        <meta charset="UTF-8"/>
        <title>用户管理</title>
    </head>

    <body>
        <div class="contentDiv">

            <h5> 《 Spring Boot 2.x 核心技术实战》第二章快速入门案例</h5>

            <legend>
                <strong>用户管理</strong>
            </legend>

            <form th:action="@{/users/{action}(action=${action})}" method="post" class="form-horizontal">

                <input type="hidden" name="id" th:value="${user.id}"/>

                <div class="form-group">
                    <label for="user_name" class="col-sm-2 control-label">名称:</label>
                    <div class="col-xs-4">
                        <input type="text" class="form-control" id="user_name" name="name" th:value="${user.name}" th:field="*{user.name}" />
                    </div>
                    <label class="col-sm-2 control-label text-danger" th:if="${#fields.hasErrors('user.name')}" th:errors="*{user.name}">姓名有误!</label>
                </div>

                <div class="form-group">
                    <label for="user_age" class="col-sm-2 control-label">年龄:</label>
                    <div class="col-xs-4">
                        <input type="text" class="form-control" id="user_age" name="age" th:value="${user.age}" th:field="*{user.age}" />
                    </div>
                    <label class="col-sm-2 control-label text-danger" th:if="${#fields.hasErrors('user.age')}" th:errors="*{user.age}">年龄有误!</label>
                </div>

                <div class="form-group">
                    <label for="user_birthday" class="col-sm-2 control-label">出生日期:</label>
                    <div class="col-xs-4">
                        <input type="date" class="form-control" id="user_birthday" name="birthday" th:value="${user.birthday}" th:field="*{user.birthday}"/>
                    </div>
                    <label class="col-sm-2 control-label text-danger" th:if="${#fields.hasErrors('user.birthday')}" th:errors="*{user.birthday}">生日有误!</label>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <input class="btn btn-primary" type="submit" value="提交"/>&nbsp;&nbsp;
                        <input class="btn" type="button" value="返回" onclick="history.back()"/>
                    </div>
                </div>
            </form>
        </div>
    </body>
</html>

================================================
FILE: chapter-4-spring-boot-validating-form-input/src/test/resources/templates/userList.html
================================================
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <script type="text/javascript" th:src="@{https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js}"></script>
        <link th:href="@{https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css}" rel="stylesheet"/>
        <link th:href="@{/css/default.css}" rel="stylesheet"/>
        <link rel="icon" th:href="@{/images/favicon.ico}" type="image/x-icon"/>
        <meta charset="UTF-8"/>
        <title>用户列表</title>
    </head>

    <body>

        <div class="contentDiv">

            <h5> 《 Spring Boot 2.x 核心技术实战》第二章快速入门案例</h5>

            <table class="table table-hover table-condensed">
                <legend>
                    <strong>用户列表</strong>
                </legend>
                <thead>
                    <tr>
                        <th>用户编号</th>
                        <th>名称</th>
                        <th>年龄</th>
                        <th>出生时间</th>
                        <th>管理</th>
                    </tr>
                </thead>
                <tbody>
                    <tr th:each="user : ${userList}">
                        <th scope="row" th:text="${user.id}"></th>
                        <td><a th:href="@{/users/update/{userId}(userId=${user.id})}" th:text="${user.name}"></a></td>
                        <td th:text="${user.age}"></td>
                        <td th:text="${user.birthday}"></td>
                        <td><a class="btn btn-danger" th:href="@{/users/delete/{userId}(userId=${user.id})}">删除</a></td>
                    </tr>
                </tbody>
            </table>

            <div><a class="btn btn-primary" href="/users/create" role="button">创建用户</a></div>
        </div>

    </body>
</html>

================================================
FILE: chapter-4-spring-boot-web-thymeleaf/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <name>chapter-4-spring-boot-web-thymeleaf</name>
    <description>《Spring Boot 2.x 核心技术实战 - 上 基础篇》第 4 章《模板引擎》Demo</description>

    <groupId>demo.springboot</groupId>
    <artifactId>chapter-4-spring-boot-web-thymeleaf</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <!-- Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- 模板引擎 Thymeleaf 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <!-- 测试依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <!-- Spring Boot Maven 插件
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            -->
        </plugins>
    </build>


    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>


================================================
FILE: chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/WebApplication.java
================================================
package demo.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 * Created by bysocket on 30/09/2017.
 */
@SpringBootApplication
public class WebApplication {
    public static void main(String[] args) {
        SpringApplication.run(WebApplication.class, args);
    }
}


================================================
FILE: chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/domain/Book.java
================================================
package demo.springboot.domain;

import java.io.Serializable;

/**
 * Book 实体类
 *
 * Created by bysocket on 30/09/2017.
 */
public class Book implements Serializable {

    /**
     * 编号
     */
    private Long id;

    /**
     * 书名
     */
    private String name;

    /**
     * 作者
     */
    private String writer;

    /**
     * 简介
     */
    private String introduction;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getWriter() {
        return writer;
    }

    public void setWriter(String writer) {
        this.writer = writer;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }
}


================================================
FILE: chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/service/BookService.java
================================================
package demo.springboot.service;

import demo.springboot.domain.Book;

import java.util.List;

/**
 * Book 业务接口层
 *
 * Created by bysocket on 30/09/2017.
 */
public interface BookService {
    /**
     * 获取所有 Book
     */
    List<Book> findAll();

    /**
     * 新增 Book
     *
     * @param book {@link Book}
     */
    Book insertByBook(Book book);

    /**
     * 更新 Book
     *
     * @param book {@link Book}
     */
    Book update(Book book);

    /**
     * 删除 Book
     *
     * @param id 编号
     */
    Book delete(Long id);

    /**
     * 获取 Book
     *
     * @param id 编号
     */
    Book findById(Long id);
}


================================================
FILE: chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/service/impl/BookServiceImpl.java
================================================
package demo.springboot.service.impl;

import demo.springboot.domain.Book;
import demo.springboot.service.BookService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Book 业务层实现
 *
 * Created by bysocket on 30/09/2017.
 */
@Service
public class BookServiceImpl implements BookService {

    // 模拟数据库,存储 Book 信息
    // 第五章《数据存储》会替换成 H2 数据源存储
    private static Map<Long, Book> BOOK_DB = new HashMap<>();

    @Override
    public List<Book> findAll() {
        return new ArrayList<>(BOOK_DB.values());
    }

    @Override
    public Book insertByBook(Book book) {
        book.setId(BOOK_DB.size() + 1L);
        BOOK_DB.put(book.getId(), book);
        return book;
    }

    @Override
    public Book update(Book book) {
        BOOK_DB.put(book.getId(), book);
        return book;
    }

    @Override
    public Book delete(Long id) {
        return BOOK_DB.remove(id);
    }

    @Override
    public Book findById(Long id) {
        return BOOK_DB.get(id);
    }
}


================================================
FILE: chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/web/BookController.java
================================================
package demo.springboot.web;

import demo.springboot.domain.Book;
import demo.springboot.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

/**
 * Book 控制层
 *
 * Created by bysocket on 30/09/2017.
 */
@Controller
@RequestMapping(value = "/book")
public class BookController {

    private static final String BOOK_FORM_PATH_NAME = "bookForm";
    private static final String BOOK_LIST_PATH_NAME = "bookList";
    private static final String REDIRECT_TO_BOOK_URL = "redirect:/book";

    @Autowired
    BookService bookService;

    /**
     * 获取 Book 列表
     * 处理 "/book" 的 GET 请求,用来获取 Book 列表
     */
    @RequestMapping(method = RequestMethod.GET)
    public String getBookList(ModelMap map) {
        map.addAttribute("bookList",bookService.findAll());
        return BOOK_LIST_PATH_NAME;
    }

    /**
     * 获取创建 Book 表单
     */
    @RequestMapping(value = "/create", method = RequestMethod.GET)
    public String createBookForm(ModelMap map) {
        map.addAttribute("book", new Book());
        map.addAttribute("action", "create");
        return BOOK_FORM_PATH_NAME;
    }

    /**
     * 创建 Book
     * 处理 "/book/create" 的 POST 请求,用来新建 Book 信息
     * 通过 @ModelAttribute 绑定表单实体参数,也通过 @RequestParam 传递参数
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public String postBook(@ModelAttribute Book book) {
        bookService.insertByBook(book);
        return REDIRECT_TO_BOOK_URL;
    }

    /**
     * 获取更新 Book 表单
     *    处理 "/book/update/{id}" 的 GET 请求,通过 URL 中的 id 值获取 Book 信息
     *    URL 中的 id ,通过 @PathVariable 绑定参数
     */
    @RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
    public String getUser(@PathVariable Long id, ModelMap map) {
        map.addAttribute("book", bookService.findById(id));
        map.addAttribute("action", "update");
        return BOOK_FORM_PATH_NAME;
    }

    /**
     * 更新 Book
     * 处理 "/update" 的 PUT 请求,用来更新 Book 信息
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public String putBook(@ModelAttribute Book book) {
        bookService.update(book);
        return REDIRECT_TO_BOOK_URL;
    }

    /**
     * 删除 Book
     * 处理 "/book/{id}" 的 GET 请求,用来删除 Book 信息
     */
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    public String deleteBook(@PathVariable Long id) {
        bookService.delete(id);
        return REDIRECT_TO_BOOK_URL;
    }

}


================================================
FILE: chapter-4-spring-boot-web-thymeleaf/src/main/resources/application.properties
================================================


================================================
FILE: chapter-4-spring-boot-web-thymeleaf/src/main/resources/static/css/default.css
================================================
/* contentDiv */
.contentDiv {padding:20px 60px;}

================================================
FILE: chapter-4-spring-boot-web-thymeleaf/src/main/resources/templates/bookForm.html
================================================
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <script type="text/javascript" th:src="@{https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js}"></script>
    <link th:href="@{https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/default.css}" rel="stylesheet"/>
    <link rel="icon" th:href="@{/images/favicon.ico}" type="image/x-icon"/>
    <meta charset="UTF-8"/>
    <title>书籍管理</title>
</head>

<body>
<div class="contentDiv">

    <h5>《Spring Boot 2.x 核心技术实战 - 上 基础篇》第 4 章《模板引擎》Demo </h5>

    <legend>
        <strong>书籍管理</strong>
    </legend>

    <form th:action="@{/book/{action}(action=${action})}" method="post" class="form-horizontal">

        <input type="hidden" name="id" th:value="${book.id}"/>

        <div class="form-group">
            <label for="book_name" class="col-sm-2 control-label">书名:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="book_name" name="name" th:value="${book.name}"
                       th:field="*{book.name}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="book_writer" class="col-sm-2 control-label">作者:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="book_writer" name="writer" th:value="${book.writer}"
                       th:field="*{book.writer}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="book_introduction" class="col-sm-2 control-label">简介:</label>
            <div class="col-xs-4">
                <textarea class="form-control" id="book_introduction" rows="3" name="introduction"
                          th:value="${book.introduction}" th:field="*{book.introduction}"></textarea>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <input class="btn btn-primary" type="submit" value="提交"/>&nbsp;&nbsp;
                <input class="btn" type="button" value="返回" onclick="history.back()"/>
            </div>
        </div>
    </form>
</div>
</body>
</html>

================================================
FILE: chapter-4-spring-boot-web-thymeleaf/src/main/resources/templates/bookList.html
================================================
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <script type="text/javascript" th:src="@{https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js}"></script>
    <link th:href="@{https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/default.css}" rel="stylesheet"/>
    <link rel="icon" th:href="@{/images/favicon.ico}" type="image/x-icon"/>
    <meta charset="UTF-8"/>
    <title>书籍列表</title>
</head>

<body>

<div class="contentDiv">

    <h5> 《Spring Boot 2.x 核心技术实战 - 上 基础篇》第 4 章《模板引擎》Demo </h5>

    <table class="table table-hover table-condensed">
        <legend>
            <strong>书籍列表</strong>
        </legend>
        <thead>
        <tr>
            <th>书籍编号</th>
            <th>书名</th>
            <th>作者</th>
            <th>简介</th>
            <th>管理</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="book : ${bookList}">
            <th scope="row" th:text="${book.id}"></th>
            <td><a th:href="@{/book/update/{bookId}(bookId=${book.id})}" th:text="${book.name}"></a></td>
            <td th:text="${book.writer}"></td>
            <td th:text="${book.introduction}"></td>
            <td><a class="btn btn-danger" th:href="@{/book/delete/{bookId}(bookId=${book.id})}">删除</a></td>
        </tr>
        </tbody>
    </table>

    <div><a class="btn btn-primary" href="/book/create" role="button">新增书籍</a></div>
</div>

</body>
</html>

================================================
FILE: chapter-4-spring-boot-web-thymeleaf/src/test/java/demo/springboot/WebApplicationTests.java
================================================
package demo.springboot;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class WebApplicationTests {

	@Test
	public void contextLoads() {
	}

}


================================================
FILE: chapter-5-spring-boot-data-jpa/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <name>chapter-5-spring-boot-data-jpa</name>
    <description>《Spring Boot 2.x 核心技术实战 - 上 基础篇》第 5 章《数据存储》Demo</description>

    <groupId>demo.springboot</groupId>
    <artifactId>chapter-5-spring-boot-data-jpa</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <!-- Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- 模板引擎 Thymeleaf 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <!-- Spring Data JPA 依赖 :: 数据持久层框架 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <!-- h2 数据源依赖 -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- 测试依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <!-- Spring Boot Maven 插件
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            -->
        </plugins>
    </build>


    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>


================================================
FILE: chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/WebApplication.java
================================================
package demo.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 * Created by bysocket on 30/09/2017.
 */
@SpringBootApplication
public class WebApplication {
    public static void main(String[] args) {
        SpringApplication.run(WebApplication.class, args);
    }
}


================================================
FILE: chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/domain/Book.java
================================================
package demo.springboot.domain;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;

/**
 * Book 实体类
 *
 * Created by bysocket on 30/09/2017.
 */
@Entity
public class Book implements Serializable {

    /**
     * 编号
     */
    @Id
    @GeneratedValue
    private Long id;

    /**
     * 书名
     */
    private String name;

    /**
     * 作者
     */
    private String writer;

    /**
     * 简介
     */
    private String introduction;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getWriter() {
        return writer;
    }

    public void setWriter(String writer) {
        this.writer = writer;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }
}


================================================
FILE: chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/domain/BookRepository.java
================================================
package demo.springboot.domain;

import org.springframework.data.jpa.repository.JpaRepository;

/**
 * Book 数据持久层操作接口
 *
 * Created by bysocket on 09/10/2017.
 */
public interface BookRepository extends JpaRepository<Book, Long> {
}


================================================
FILE: chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/service/BookService.java
================================================
package demo.springboot.service;

import demo.springboot.domain.Book;

import java.util.List;

/**
 * Book 业务接口层
 *
 * Created by bysocket on 30/09/2017.
 */
public interface BookService {
    /**
     * 获取所有 Book
     */
    List<Book> findAll();

    /**
     * 新增 Book
     *
     * @param book {@link Book}
     */
    Book insertByBook(Book book);

    /**
     * 更新 Book
     *
     * @param book {@link Book}
     */
    Book update(Book book);

    /**
     * 删除 Book
     *
     * @param id 编号
     */
    Book delete(Long id);

    /**
     * 获取 Book
     *
     * @param id 编号
     */
    Book findById(Long id);
}


================================================
FILE: chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/service/impl/BookServiceImpl.java
================================================
package demo.springboot.service.impl;

import demo.springboot.domain.Book;
import demo.springboot.domain.BookRepository;
import demo.springboot.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Book 业务层实现
 *
 * Created by bysocket on 30/09/2017.
 */
@Service
public class BookServiceImpl implements BookService {

    @Autowired
    BookRepository bookRepository;

    @Override
    public List<Book> findAll() {
        return bookRepository.findAll();
    }

    @Override
    public Book insertByBook(Book book) {
        return bookRepository.save(book);
    }

    @Override
    public Book update(Book book) {
        return bookRepository.save(book);
    }

    @Override
    public Book delete(Long id) {
        Book book = bookRepository.findById(id).get();
        bookRepository.delete(book);
        return book;
    }

    @Override
    public Book findById(Long id) {
        return bookRepository.findById(id).get();
    }
}


================================================
FILE: chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/web/BookController.java
================================================
package demo.springboot.web;

import demo.springboot.domain.Book;
import demo.springboot.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

/**
 * Book 控制层
 *
 * Created by bysocket on 30/09/2017.
 */
@Controller
@RequestMapping(value = "/book")
public class BookController {

    private static final String BOOK_FORM_PATH_NAME = "bookForm";
    private static final String BOOK_LIST_PATH_NAME = "bookList";
    private static final String REDIRECT_TO_BOOK_URL = "redirect:/book";

    @Autowired
    BookService bookService;

    /**
     * 获取 Book 列表
     * 处理 "/book" 的 GET 请求,用来获取 Book 列表
     */
    @RequestMapping(method = RequestMethod.GET)
    public String getBookList(ModelMap map) {
        map.addAttribute("bookList",bookService.findAll());
        return BOOK_LIST_PATH_NAME;
    }

    /**
     * 获取创建 Book 表单
     */
    @RequestMapping(value = "/create", method = RequestMethod.GET)
    public String createBookForm(ModelMap map) {
        map.addAttribute("book", new Book());
        map.addAttribute("action", "create");
        return BOOK_FORM_PATH_NAME;
    }

    /**
     * 创建 Book
     * 处理 "/book/create" 的 POST 请求,用来新建 Book 信息
     * 通过 @ModelAttribute 绑定表单实体参数,也通过 @RequestParam 传递参数
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public String postBook(@ModelAttribute Book book) {
        bookService.insertByBook(book);
        return REDIRECT_TO_BOOK_URL;
    }

    /**
     * 获取更新 Book 表单
     *    处理 "/book/update/{id}" 的 GET 请求,通过 URL 中的 id 值获取 Book 信息
     *    URL 中的 id ,通过 @PathVariable 绑定参数
     */
    @RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
    public String getUser(@PathVariable Long id, ModelMap map) {
        map.addAttribute("book", bookService.findById(id));
        map.addAttribute("action", "update");
        return BOOK_FORM_PATH_NAME;
    }

    /**
     * 更新 Book
     * 处理 "/update" 的 PUT 请求,用来更新 Book 信息
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public String putBook(@ModelAttribute Book book) {
        bookService.update(book);
        return REDIRECT_TO_BOOK_URL;
    }

    /**
     * 删除 Book
     * 处理 "/book/{id}" 的 GET 请求,用来删除 Book 信息
     */
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    public String deleteBook(@PathVariable Long id) {
        bookService.delete(id);
        return REDIRECT_TO_BOOK_URL;
    }

}


================================================
FILE: chapter-5-spring-boot-data-jpa/src/main/resources/application.properties
================================================
## 是否启动日志 SQL 语句
spring.jpa.show-sql=true

================================================
FILE: chapter-5-spring-boot-data-jpa/src/main/resources/static/css/default.css
================================================
/* contentDiv */
.contentDiv {padding:20px 60px;}

================================================
FILE: chapter-5-spring-boot-data-jpa/src/main/resources/templates/bookForm.html
================================================
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <script type="text/javascript" th:src="@{https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js}"></script>
    <link th:href="@{https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/default.css}" rel="stylesheet"/>
    <link rel="icon" th:href="@{/images/favicon.ico}" type="image/x-icon"/>
    <meta charset="UTF-8"/>
    <title>书籍管理</title>
</head>

<body>
<div class="contentDiv">

    <h5>《Spring Boot 2.x 核心技术实战 - 上 基础篇》第 5 章《数据存储》Demo </h5>

    <legend>
        <strong>书籍管理</strong>
    </legend>

    <form th:action="@{/book/{action}(action=${action})}" method="post" class="form-horizontal">

        <input type="hidden" name="id" th:value="${book.id}"/>

        <div class="form-group">
            <label for="book_name" class="col-sm-2 control-label">书名:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="book_name" name="name" th:value="${book.name}"
                       th:field="*{book.name}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="book_writer" class="col-sm-2 control-label">作者:</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" id="book_writer" name="writer" th:value="${book.writer}"
                       th:field="*{book.writer}"/>
            </div>
        </div>

        <div class="form-group">
            <label for="book_introduction" class="col-sm-2 control-label">简介:</label>
            <div class="col-xs-4">
                <textarea class="form-control" id="book_introduction" rows="3" name="introduction"
                          th:value="${book.introduction}" th:field="*{book.introduction}"></textarea>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <input class="btn btn-primary" type="submit" value="提交"/>&nbsp;&nbsp;
                <input class="btn" type="button" value="返回" onclick="history.back()"/>
            </div>
        </div>
    </form>
</div>
</body>
</html>

================================================
FILE: chapter-5-spring-boot-data-jpa/src/main/resources/templates/bookList.html
================================================
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <script type="text/javascript" th:src="@{https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js}"></script>
    <link th:href="@{https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/default.css}" rel="stylesheet"/>
    <link rel="icon" th:href="@{/images/favicon.ico}" type="image/x-icon"/>
    <meta charset="UTF-8"/>
    <title>书籍列表</title>
</head>

<body>

<div class="contentDiv">

    <h5>《Spring Boot 2.x 核心技术实战 - 上 基础篇》第 5 章《数据存储》Demo </h5>

    <table class="table table-hover table-condensed">
        <legend>
            <strong>书籍列表</strong>
        </legend>
        <thead>
        <tr>
            <th>书籍编号</th>
            <th>书名</th>
            <th>作者</th>
            <th>简介</th>
            <th>管理</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="book : ${bookList}">
            <th scope="row" th:text="${book.id}"></th>
            <td><a th:href="@{/book/update/{bookId}(bookId=${book.id})}" th:text="${book.name}"></a></td>
            <td th:text="${book.writer}"></td>
            <td th:text="${book.introduction}"></td>
            <td><a class="btn btn-danger" th:href="@{/book/delete/{bookId}(bookId=${book.id})}">删除</a></td>
        </tr>
        </tbody>
    </table>

    <div><a class="btn btn-primary" href="/book/create" role="button">新增书籍</a></div>
</div>

</body>
</html>

================================================
FILE: chapter-5-spring-boot-data-jpa/src/test/java/demo/springboot/WebApplicationTests.java
================================================
package demo.springboot;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class WebApplicationTests {

	@Test
	public void contextLoads() {
	}

}


================================================
FILE: chapter-5-spring-boot-paging-sorting/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>spring.boot.core</groupId>
    <artifactId>chapter-5-spring-boot-paging-sorting</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>chapter-5-spring-boot-paging-sorting</name>
    <description>第五章数据分页排序案例</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.M4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <!-- Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- 单元测试依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Spring Data JPA 依赖 :: 数据持久层框架 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <!-- h2 数据源连接驱动 -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <!-- Spring Boot Maven 插件 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.1.3.RELEASE</version>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/libs-milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>


================================================
FILE: chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/PagingSortingApplication.java
================================================
package spring.boot.core;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * 应用启动程序
 *
 * Created by bysocket on 18/09/2017.
 */
@SpringBootApplication
public class PagingSortingApplication {

	public static void main(String[] args) {
		SpringApplication.run(PagingSortingApplication.class, args);
	}
}


================================================
FILE: chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/domain/User.java
================================================
package spring.boot.core.domain;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;

/**
 * 用户实体类
 *
 * Created by bysocket on 18/09/2017.
 */
@Entity
public class User implements Serializable {

    /**
     * 编号
     */
    @Id
    @GeneratedValue
    private Long id;

    /**
     * 名称
     */
    private String name;

    /**
     * 年龄
     */
    private Integer age;

    /**
     * 出生时间
     */
    private String birthday;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", birthday=" + birthday +
                '}';
    }
}


================================================
FILE: chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/domain/UserRepository.java
================================================
package spring.boot.core.domain;

import org.springframework.data.repository.PagingAndSortingRepository;

/**
 * 用户持久层操作接口
 *
 * Created by bysocket on 18/09/2017.
 */
public interface UserRepository extends PagingAndSortingRepository<User, Long> {

}


================================================
FILE: chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/service/UserService.java
================================================
package spring.boot.core.service;


import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import spring.boot.core.domain.User;

/**
 * User 业务层接口
 *
 * Created by bysocket on 18/09/2017.
 */
public interface UserService {

    /**
     * 获取用户分页列表
     *
     * @param pageable
     * @return
     */
    Page<User> findByPage(Pageable pageable);

    /**
     * 新增用户
     *
     * @param user
     * @return
     */
    User insertByUser(User user);
}


================================================
FILE: chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/service/impl/UserServiceImpl.java
================================================
package spring.boot.core.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import spring.boot.core.domain.User;
import spring.boot.core.domain.UserRepository;
import spring.boot.core.service.UserService;

/**
 * User 业务层实现
 *
 * Created by bysocket on 18/09/2017.
 */
@Service
public class UserServiceImpl implements UserService {

    private static final Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    UserRepository userRepository;

    @Override
    public Page<User> findByPage(Pageable pageable) {
        LOGGER.info(" \n 分页查询用户:"
                + " PageNumber = " + pageable.getPageNumber()
                + " PageSize = " + pageable.getPageSize());
        return userRepository.findAll(pageable);
    }

    @Override
    public User insertByUser(User user) {
        LOGGER.info("新增用户:" + user.toString());
        return userRepository.save(user);
    }
}


================================================
FILE: chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/web/UserController.java
================================================
package spring.boot.core.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
import spring.boot.core.domain.User;
import spring.boot.core.service.UserService;

/**
 * 用户控制层
 *
 * Created by bysocket on 18/09/2017.
 */
@RestController
@RequestMapping(value = "/users")     // 通过这里配置使下面的映射都在 /users
public class UserController {

    @Autowired
    UserService userService;          // 用户服务层

    /**
     *  获取用户分页列表
     *    处理 "/users" 的 GET 请求,用来获取用户分页列表
     *    通过 @RequestParam 传递参数,进一步实现条件查询或者分页查询
     *
     *    Pageable 支持的分页参数如下
     *    page - 当前页 从 0 开始
     *    size - 每页大小 默认值在 application.properties 配置
     */
    @RequestMapping(method = RequestMethod.GET)
    public Page<User> getUserPage(Pageable pageable) {
        return userService.findByPage(pageable);
    }

    /**
     *  创建用户
     *    处理 "/users" 的 POST 请求,用来获取用户列表
     *    通过 @RequestBody 绑定实体类参数
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public User postUser(@RequestBody User user) {
        return userService.insertByUser(user);
    }

}

================================================
FILE: chapter-5-spring-boot-paging-sorting/src/main/resources/application.properties
================================================
## 是否显示 SQL 语句
spring.jpa.show-sql=true

## DATA WEB 相关配置 {@link SpringDataWebProperties}
## 分页大小 默认为 20
spring.data.web.pageable.default-page-size=3
## 当前页参数名 默认为 page
spring.data.web.pageable.page-parameter=pageNumber
## 当前页参数名 默认为 size
spring.data.web.pageable.size-parameter=pageSize
## 字段排序参数名 默认为 sort
spring.data.web.sort.sort-parameter=orderBy

================================================
FILE: chapter-5-spring-boot-paging-sorting/src/test/java/spring/boot/core/PagingSortingApplicationTests.java
================================================
package spring.boot.core;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class PagingSortingApplicationTests {

	@Test
	public void contextLoads() {
	}

}


================================================
FILE: pom.xml
================================================
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<name>springboot-learning-example</name>

	<groupId>springboot</groupId>
	<artifactId>springboot-learning-example</artifactId>
	<version>1.0-SNAPSHOT</version>
	<packaging>pom</packaging>

	<modules>
		<!-- WebFlux 异常处理 -->
		<module>2-x-spring-boot-webflux-handling-errors</module>
		<!-- 动态运行 groovy 脚本 --> 
    	<module>2-x-spring-boot-groovy</module>

		<!-- 第 1 章《Spring Boot 入门》 -->
		<module>chapter-1-spring-boot-quickstart</module>
		<!-- 第 2 章《配置》 -->
		<module>chapter-2-spring-boot-config</module>
		<!-- 第 3 章《Web 开发》 -->
		<module>chapter-3-spring-boot-web</module>
		<!-- 第 4 章《模板引擎》 -->
		<module>chapter-4-spring-boot-web-thymeleaf</module>
		<!-- 第 5 章《数据存储》 -->
		<module>chapter-5-spring-boot-data-jpa</module>
		<!-- 第 4 章表单校验案例 -->
		<module>chapter-4-spring-boot-validating-form-input</module>
		<!-- 第 4 章数据分页排序案例 -->
		<module>chapter-5-spring-boot-paging-sorting</module>

		<!-- Spring Data ES 篇 -->
		<module>spring-data-elasticsearch-crud</module>
		<module>spring-data-elasticsearch-query</module>

		<!-- Spring Boot 之配置文件详解 -->
		<module>springboot-configuration</module>

		<!-- Spring Boot 整合 Dubbo/ZooKeeper 详解 SOA 案例 -->
		<module>springboot-dubbo-server</module>
		<module>springboot-dubbo-client</module>

		<!-- Spring Boot 整合 Elasticsearch -->
		<module>springboot-elasticsearch</module>

		<!-- Spring Boot 集成 FreeMarker -->
		<module>springboot-freemarker</module>

		<!-- Spring Boot 整合 HBase -->
		<module>springboot-hbase</module>

		<!-- Spring Boot 之 HelloWorld 详解 -->
		<module>springboot-helloworld</module>

		<!-- 数据缓存篇 -->
		<!-- Spring Boot 整合 Mybatis 的完整 Web 案例 -->
		<module>springboot-mybatis</module>
		<!-- Spring Boot 整合 Mybatis Annotation 注解案例 -->
		<module>springboot-mybatis-annotation</module>
		<!-- Spring Boot 整合 Mybatis 实现 Druid 多数据源配置 -->
		<module>springboot-mybatis-mutil-datasource</module>
		<!-- Spring Boot 整合 Redis 实现缓存 -->
		<module>springboot-mybatis-redis</module>
		<!-- Spring Boot 注解实现整合 Redis 实现缓存 -->
		<module>springboot-mybatis-redis-annotation</module>

		<!-- Spring Boot 实现 Restful 服务,基于 HTTP / JSON 传输 -->
		<module>springboot-restful</module>

		<!-- Spring Boot 之配置文件详解 -->
		<module>springboot-properties</module>

		<!-- Spring Boot HTTP over JSON 的错误码异常处理 -->
		<module>springboot-validation-over-json</module>

		<!-- Spring Boot 2.0 WebFlux -->
    <!-- Spring Boot WebFlux 快速入门 -->
    <module>springboot-webflux-1-quickstart</module>
    <!-- Spring Boot WebFlux 实现 Restful 服务,基于 HTTP / JSON 传输 -->
    <module>springboot-webflux-2-restful</module>
    <module>springboot-webflux-3-mongodb</module>
    <module>springboot-webflux-4-thymeleaf</module>
    <module>springboot-webflux-5-thymeleaf-mongodb</module>
		<module>springboot-webflux-6-redis</module>
		<module>springboot-webflux-7-redis-cache</module>
	</modules>
</project>


================================================
FILE: spring-data-elasticsearch-crud/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>springboot</groupId>
    <artifactId>spring-data-elasticsearch-crud</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>spring-data-elasticsearch-crud</name>

    <!-- Spring Boot 启动父依赖 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.1.RELEASE</version>
    </parent>

    <dependencies>

        <!-- Spring Boot Elasticsearch 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>

        <!-- Spring Boot Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>
</project>


================================================
FILE: spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/Application.java
================================================
package org.spring.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 * Created by bysocket on 16/4/26.
 */
// Spring Boot 应用的标识
@SpringBootApplication
public class Application {

  public static void main(String[] args) {
        // 程序启动入口
        // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件
        SpringApplication.run(Application.class,args);
    }
}


================================================
FILE: spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/controller/CityRestController.java
================================================
package org.spring.springboot.controller;

import org.spring.springboot.domain.City;
import org.spring.springboot.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 城市 Controller 实现 Restful HTTP 服务
 * <p>
 * Created by bysocket on 03/05/2017.
 */
@RestController
public class CityRestController {

    @Autowired
    private CityService cityService;

    /**
     * 插入 ES 新城市
     *
     * @param city
     * @return
     */
    @RequestMapping(value = "/api/city", method = RequestMethod.POST)
    public Long createCity(@RequestBody City city) {
        return cityService.saveCity(city);
    }

    /**
     * AND 语句查询
     *
     * @param description
     * @param score
     * @return
     */
    @RequestMapping(value = "/api/city/and/find", method = RequestMethod.GET)
    public List<City> findByDescriptionAndScore(@RequestParam(value = "description") String description,
                                                @RequestParam(value = "score") Integer score) {
        return cityService.findByDescriptionAndScore(description, score);
    }

    /**
     * OR 语句查询
     *
     * @param description
     * @param score
     * @return
     */
    @RequestMapping(value = "/api/city/or/find", method = RequestMethod.GET)
    public List<City> findByDescriptionOrScore(@RequestParam(value = "description") String description,
                                               @RequestParam(value = "score") Integer score) {
        return cityService.findByDescriptionOrScore(description, score);
    }

    /**
     * 查询城市描述
     *
     * @param description
     * @return
     */
    @RequestMapping(value = "/api/city/description/find", method = RequestMethod.GET)
    public List<City> findByDescription(@RequestParam(value = "description") String description) {
        return cityService.findByDescription(description);
    }

    /**
     * NOT 语句查询
     *
     * @param description
     * @return
     */
    @RequestMapping(value = "/api/city/description/not/find", method = RequestMethod.GET)
    public List<City> findByDescriptionNot(@RequestParam(value = "description") String description) {
        return cityService.findByDescriptionNot(description);
    }

    /**
     * LIKE 语句查询
     *
     * @param description
     * @return
     */
    @RequestMapping(value = "/api/city/like/find", method = RequestMethod.GET)
    public List<City> findByDescriptionLike(@RequestParam(value = "description") String description) {
        return cityService.findByDescriptionLike(description);
    }
}


================================================
FILE: spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/domain/City.java
================================================
package org.spring.springboot.domain;

import org.springframework.data.elasticsearch.annotations.Document;

import java.io.Serializable;

/**
 * 城市实体类
 * <p>
 * Created by bysocket on 03/05/2017.
 */
@Document(indexName = "province", type = "city")
public class City implements Serializable {

    private static final long serialVersionUID = -1L;

    /**
     * 城市编号
     */
    private Long id;

    /**
     * 城市名称
     */
    private String name;

    /**
     * 描述
     */
    private String description;

    /**
     * 城市评分
     */
    private Integer score;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }
}


================================================
FILE: spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/repository/CityRepository.java
================================================
package org.spring.springboot.repository;

import org.spring.springboot.domain.City;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.List;

/**
 * ES 操作类
 * <p>
 * Created by bysocket on 17/05/2017.
 */
public interface CityRepository extends ElasticsearchRepository<City, Long> {
    /**
     * AND 语句查询
     *
     * @param description
     * @param score
     * @return
     */
    List<City> findByDescriptionAndScore(String description, Integer score);

    /**
     * OR 语句查询
     *
     * @param description
     * @param score
     * @return
     */
    List<City> findByDescriptionOrScore(String description, Integer score);

    /**
     * 查询城市描述
     *
     * 等同于下面代码
     * @Query("{\"bool\" : {\"must\" : {\"term\" : {\"description\" : \"?0\"}}}}")
     * Page<City> findByDescription(String description, Pageable pageable);
     *
     * @param description
     * @param page
     * @return
     */
    Page<City> findByDescription(String description, Pageable page);

    /**
     * NOT 语句查询
     *
     * @param description
     * @param page
     * @return
     */
    Page<City> findByDescriptionNot(String description, Pageable page);

    /**
     * LIKE 语句查询
     *
     * @param description
     * @param page
     * @return
     */
    Page<City> findByDescriptionLike(String description, Pageable page);

}


================================================
FILE: spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/service/CityService.java
================================================

package org.spring.springboot.service;

import org.spring.springboot.domain.City;

import java.util.List;

/**
 * 城市 ES 业务接口类
 *
 */
public interface CityService {

    /**
     * 新增 ES 城市信息
     *
     * @param city
     * @return
     */
    Long saveCity(City city);

    /**
     * AND 语句查询
     *
     * @param description
     * @param score
     * @return
     */
    List<City> findByDescriptionAndScore(String description, Integer score);

    /**
     * OR 语句查询
     *
     * @param description
     * @param score
     * @return
     */
    List<City> findByDescriptionOrScore(String description, Integer score);

    /**
     * 查询城市描述
     *
     * @param description
     * @return
     */
    List<City> findByDescription(String description);

    /**
     * NOT 语句查询
     *
     * @param description
     * @return
     */
    List<City> findByDescriptionNot(String description);

    /**
     * LIKE 语句查询
     *
     * @param description
     * @return
     */
    List<City> findByDescriptionLike(String description);
}

================================================
FILE: spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/service/impl/CityESServiceImpl.java
================================================
package org.spring.springboot.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spring.springboot.domain.City;
import org.spring.springboot.repository.CityRepository;
import org.spring.springboot.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 城市 ES 业务逻辑实现类
 * <p>
 * Created by bysocket on 07/02/2017.
 */
@Service
public class CityESServiceImpl implements CityService {

    private static final Logger LOGGER = LoggerFactory.getLogger(CityESServiceImpl.class);

    // 分页参数 -> TODO 代码可迁移到具体项目的公共 common 模块
    private static final Integer pageNumber = 0;
    private static final Integer pageSize = 10;
    Pageable pageable = new PageRequest(pageNumber, pageSize);

    // ES 操作类
    @Autowired
    CityRepository cityRepository;

    public Long saveCity(City city) {
        City cityResult = cityRepository.save(city);
        return cityResult.getId();
    }

    public List<City> findByDescriptionAndScore(String description, Integer score) {
        return cityRepository.findByDescriptionAndScore(description, score);
    }

    public List<City> findByDescriptionOrScore(String description, Integer score) {
        return cityRepository.findByDescriptionOrScore(description, score);
    }

    public List<City> findByDescription(String description) {
        return cityRepository.findByDescription(description, pageable).getContent();
    }

    public List<City> findByDescriptionNot(String description) {
        return cityRepository.findByDescriptionNot(description, pageable).getContent();
    }

    public List<City> findByDescriptionLike(String description) {
        return cityRepository.findByDescriptionLike(description, pageable).getContent();
    }

}


================================================
FILE: spring-data-elasticsearch-crud/src/main/resources/application.properties
================================================
# ES
spring.data.elasticsearch.repositories.enabled = true
spring.data.elasticsearch.cluster-nodes = 127.0.0.1:9300

================================================
FILE: spring-data-elasticsearch-query/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>springboot</groupId>
    <artifactId>spring-data-elasticsearch-query</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>spring-data-elasticsearch-query</name>

    <!-- Spring Boot 启动父依赖 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.1.RELEASE</version>
    </parent>

    <dependencies>

        <!-- Spring Boot Elasticsearch 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>

        <!-- Spring Boot Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>
</project>


================================================
FILE: spring-data-elasticsearch-query/src/main/java/org/spring/springboot/Application.java
================================================
package org.spring.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 * Created by bysocket on 20/06/2017.
 */
// Spring Boot 应用的标识
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        // 程序启动入口
        // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件
        SpringApplication.run(Application.class,args);
    }
}


================================================
FILE: spring-data-elasticsearch-query/src/main/java/org/spring/springboot/controller/CityRestController.java
================================================
package org.spring.springboot.controller;

import org.spring.springboot.domain.City;
import org.spring.springboot.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 城市 Controller 实现 Restful HTTP 服务
 * <p>
 * Created by bysocket on 20/06/2017.
 */
@RestController
public class CityRestController {

    @Autowired
    private CityService cityService;

    /**
     * 插入 ES 新城市
     *
     * @param city
     * @return
     */
    @RequestMapping(value = "/api/city", method = RequestMethod.POST)
    public Long createCity(@RequestBody City city) {
        return cityService.saveCity(city);
    }

    /**
     * 搜索返回分页结果
     *
     * @param pageNumber 当前页码
     * @param pageSize 每页大小
     * @param searchContent 搜索内容
     * @return
     */
    @RequestMapping(value = "/api/city/search", method = RequestMethod.GET)
    public List<City> searchCity(@RequestParam(value = "pageNumber") Integer pageNumber,
                                                @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                                @RequestParam(value = "searchContent") String searchContent) {
        return cityService.searchCity(pageNumber, pageSize,searchContent);
    }
}


================================================
FILE: spring-data-elasticsearch-query/src/main/java/org/spring/springboot/domain/City.java
================================================
package org.spring.springboot.domain;

import org.springframework.data.elasticsearch.annotations.Document;

import java.io.Serializable;

/**
 * 城市实体类
 * <p>
 * Created by bysocket on 20/06/2017.
 */
@Document(indexName = "province", type = "city")
public class City implements Serializable {

    private static final long serialVersionUID = -1L;

    /**
     * 城市编号
     */
    private Long id;

    /**
     * 城市名称
     */
    private String name;

    /**
     * 描述
     */
    private String description;

    /**
     * 城市评分
     */
    private Integer score;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }
}


================================================
FILE: spring-data-elasticsearch-query/src/main/java/org/spring/springboot/repository/CityRepository.java
================================================
package org.spring.springboot.repository;

import org.spring.springboot.domain.City;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.List;

/**
 * ES 操作类
 * <p>
 * Created by bysocket on 20/06/2017.
 */
public interface CityRepository extends ElasticsearchRepository<City, Long> {

}


================================================
FILE: spring-data-elasticsearch-query/src/main/java/org/spring/springboot/service/CityService.java
================================================

package org.spring.springboot.service;

import org.spring.springboot.domain.City;

import java.util.List;

/**
 * 城市 ES 业务接口类
 *
 */
public interface CityService {

    /**
     * 新增 ES 城市信息
     *
     * @param city
     * @return
     */
    Long saveCity(City city);

    /**
     * 搜索词搜索,分页返回城市信息
     *
     * @param pageNumber 当前页码
     * @param pageSize 每页大小
     * @param searchContent 搜索内容
     * @return
     */
    List<City> searchCity(Integer pageNumber, Integer pageSize, String searchContent);
}

================================================
FILE: spring-data-elasticsearch-query/src/main/java/org/spring/springboot/service/impl/CityESServiceImpl.java
================================================
package org.spring.springboot.service.impl;

import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spring.springboot.domain.City;
import org.spring.springboot.repository.CityRepository;
import org.spring.springboot.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 城市 ES 业务逻辑实现类
 * <p>
 * Created by bysocket on 20/06/2017.
 */
@Service
public class CityESServiceImpl implements CityService {

    private static final Logger LOGGER = LoggerFactory.getLogger(CityESServiceImpl.class);

    /* 分页参数 */
    Integer PAGE_SIZE = 12;          // 每页数量
    Integer DEFAULT_PAGE_NUMBER = 0; // 默认当前页码

    /* 搜索模式 */
    String SCORE_MODE_SUM = "sum"; // 权重分求和模式
    Float  MIN_SCORE = 10.0F;      // 由于无相关性的分值默认为 1 ,设置权重分最小值为 10

    @Autowired
    CityRepository cityRepository; // ES 操作类

    public Long saveCity(City city) {
        City cityResult = cityRepository.save(city);
        return cityResult.getId();
    }

    @Override
    public List<City> searchCity(Integer pageNumber, Integer pageSize, String searchContent) {

        // 校验分页参数
        if (pageSize == null || pageSize <= 0) {
            pageSize = PAGE_SIZE;
        }

        if (pageNumber == null || pageNumber < DEFAULT_PAGE_NUMBER) {
            pageNumber = DEFAULT_PAGE_NUMBER;
        }

        LOGGER.info("\n searchCity: searchContent [" + searchContent + "] \n ");

        // 构建搜索查询
        SearchQuery searchQuery = getCitySearchQuery(pageNumber,pageSize,searchContent);

        LOGGER.info("\n searchCity: searchContent [" + searchContent + "] \n DSL  = \n " + searchQuery.getQuery().toString());

        Page<City> cityPage = cityRepository.search(searchQuery);
        return cityPage.getContent();
    }

    /**
     * 根据搜索词构造搜索查询语句
     *
     * 代码流程:
     *      - 权重分查询
     *      - 短语匹配
     *      - 设置权重分最小值
     *      - 设置分页参数
     *
     * @param pageNumber 当前页码
     * @param pageSize 每页大小
     * @param searchContent 搜索内容
     * @return
     */
    private SearchQuery getCitySearchQuery(Integer pageNumber, Integer pageSize,String searchContent) {
        // 短语匹配到的搜索词,求和模式累加权重分
        // 权重分查询 https://www.elastic.co/guide/cn/elasticsearch/guide/current/function-score-query.html
        //   - 短语匹配 https://www.elastic.co/guide/cn/elasticsearch/guide/current/phrase-matching.html
        //   - 字段对应权重分设置,可以优化成 enum
        //   - 由于无相关性的分值默认为 1 ,设置权重分最小值为 10
        FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery()
                .add(QueryBuilders.matchPhraseQuery("name", searchContent),
                ScoreFunctionBuilders.weightFactorFunction(1000))
                .add(QueryBuilders.matchPhraseQuery("description", searchContent),
                ScoreFunctionBuilders.weightFactorFunction(500))
                .scoreMode(SCORE_MODE_SUM).setMinScore(MIN_SCORE);

        // 分页参数
        Pageable pageable = new PageRequest(pageNumber, pageSize);
        return new NativeSearchQueryBuilder()
                .withPageable(pageable)
                .withQuery(functionScoreQueryBuilder).build();
    }


}


================================================
FILE: spring-data-elasticsearch-query/src/main/resources/application.properties
================================================
# ES
spring.data.elasticsearch.repositories.enabled = true
spring.data.elasticsearch.cluster-nodes = 127.0.0.1:9300

================================================
FILE: springboot-configuration/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>springboot</groupId>
    <artifactId>springboot-configuration</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot-configuration</name>

    <!-- Spring Boot 启动父依赖 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
    </parent>

    <dependencies>
        <!-- Spring Boot web依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>
</project>


================================================
FILE: springboot-configuration/src/main/java/org/spring/springboot/Application.java
================================================
package org.spring.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 */
// Spring Boot 应用的标识
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        // 程序启动入口
        // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件
        SpringApplication.run(Application.class,args);
    }
}


================================================
FILE: springboot-configuration/src/main/java/org/spring/springboot/config/MessageConfiguration.java
================================================
package org.spring.springboot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by bysocket on 08/09/2017.
 */
@Configuration
public class MessageConfiguration {

    @Bean
    public String message() {
        return "message configuration";
    }
}


================================================
FILE: springboot-configuration/src/test/java/org/spring/springboot/config/MessageConfigurationTest.java
================================================
package org.spring.springboot.config;

import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import static org.junit.Assert.assertEquals;

/**
 * Spring Boot MessageConfiguration 测试 - {@link MessageConfiguration}
 *
 */
public class MessageConfigurationTest {

    @Test
    public void testGetMessageBean() throws Exception {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(MessageConfiguration.class);
        assertEquals("message configuration", ctx.getBean("message"));
    }

    @Test
    public void testScanPackages() throws Exception {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
        ctx.scan("org.spring.springboot");
        ctx.refresh();
        assertEquals("message configuration", ctx.getBean("message"));
    }
}


================================================
FILE: springboot-dubbo-client/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>springboot</groupId>
    <artifactId>springboot-dubbo-client</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <!-- Spring Boot 启动父依赖 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
    </parent>

    <properties>
        <dubbo-spring-boot>1.0.0</dubbo-spring-boot>
    </properties>

    <dependencies>

        <!-- Spring Boot Dubbo 依赖 -->
        <dependency>
            <groupId>io.dubbo.springboot</groupId>
            <artifactId>spring-boot-starter-dubbo</artifactId>
            <version>${dubbo-spring-boot}</version>
        </dependency>

        <!-- Spring Boot Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- Spring Boot Test 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

    </dependencies>
</project>


================================================
FILE: springboot-dubbo-client/src/main/java/org/spring/springboot/ClientApplication.java
================================================
package org.spring.springboot;

import org.spring.springboot.dubbo.CityDubboConsumerService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * Spring Boot 应用启动类
 *
 * Created by bysocket on 16/4/26.
 */
// Spring Boot 应用的标识
@SpringBootApplication
public class ClientApplication {

    public static void main(String[] args) {
        // 程序启动入口
        // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件
        ConfigurableApplicationContext run = SpringApplication.run(ClientApplication.class, args);
        CityDubboConsumerService cityService = run.getBean(CityDubboConsumerService.class);
        cityService.printCity();
    }
}


================================================
FILE: springboot-dubbo-client/src/main/java/org/spring/springboot/domain/City.java
================================================
package org.spring.springboot.domain;

import java.io.Serializable;

/**
 * 城市实体类
 *
 * Created by bysocket on 07/02/2017.
 */
public class City implements Serializable {

    private static final long serialVersionUID = -1L;

    /**
     * 城市编号
     */
    private Long id;

    /**
     * 省份编号
     */
    private Long provinceId;

    /**
     * 城市名称
     */
    private String cityName;

    /**
     * 描述
     */
    private String description;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(Long provinceId) {
        this.provinceId = provinceId;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public String toString() {
        return "City{" +
                "id=" + id +
                ", provinceId=" + provinceId +
                ", cityName='" + cityName + '\'' +
                ", description='" + description + '\'' +
                '}';
    }
}


================================================
FILE: springboot-dubbo-client/src/main/java/org/spring/springboot/dubbo/CityDubboConsumerService.java
================================================
package org.spring.springboot.dubbo;

import com.alibaba.dubbo.config.annotation.Reference;
import org.spring.springboot.domain.City;
import org.springframework.stereotype.Component;

/**
 * 城市 Dubbo 服务消费者
 *
 * Created by bysocket on 28/02/2017.
 */
@Component
public class CityDubboConsumerService {

    @Reference(version = "1.0.0")
    CityDubboService cityDubboService;

    public void printCity() {
        String cityName="温岭";
        City city = cityDubboService.findCityByName(cityName);
        System.out.println(city.toString());
    }
}


================================================
FILE: springboot-dubbo-client/src/main/java/org/spring/springboot/dubbo/CityDubboService.java
================================================
package org.spring.springboot.dubbo;

import org.spring.springboot.domain.City;

/**
 * 城市业务 Dubbo 服务层
 *
 * Created by bysocket on 28/02/2017.
 */
public interface CityDubboService {

    /**
     * 根据城市名称,查询城市信息
     * @param cityName
     */
    City findCityByName(String cityName);
}


================================================
FILE: springboot-dubbo-client/src/main/resources/application.properties
================================================
## 避免和 server 工程端口冲突
server.port=8081

## Dubbo 服务消费者配置
spring.dubbo.application.name=consumer
spring.dubbo.registry.address=zookeeper://127.0.0.1:2181
spring.dubbo.scan=org.spring.springboot.dubbo

================================================
FILE: springboot-dubbo-server/DubboProperties.md
================================================
## Dubbo 配置
# 扫描包路径
<br>spring.dubbo.scan=org.<br>spring.<br>springboot.dubbo

## Dubbo 应用配置
// 应用名称
<br>spring.dubbo.application.name=xxx

// 模块版本
<br>spring.dubbo.application.version=xxx

// 应用负责人
<br>spring.dubbo.application.owner=xxx

// 组织名(BU或部门)
<br>spring.dubbo.application.organization=xxx

// 分层
<br>spring.dubbo.application.architecture=xxx

// 环境,如:dev/test/run
<br>spring.dubbo.application.environment=xxx

// Java代码编译器
<br>spring.dubbo.application.compiler=xxx

// 日志输出方式
<br>spring.dubbo.application.logger=xxx

// 注册中心 0
<br>spring.dubbo.application.registries[0].address=zookeeper://127.0.0.1:2181=xxx
// 注册中心 1
<br>spring.dubbo.application.registries[1].address=zookeeper://127.0.0.1:2181=xxx

// 服务监控
<br>spring.dubbo.application.monitor.address=xxx

## Dubbo 注册中心配置类
// 注册中心地址
<br>spring.dubbo.application.registries.address=xxx

// 注册中心登录用户名
<br>spring.dubbo.application.registries.username=xxx

// 注册中心登录密码
<br>spring.dubbo.application.registries.password=xxx

// 注册中心缺省端口
<br>spring.dubbo.application.registries.port=xxx

// 注册中心协议
<br>spring.dubbo.application.registries.protocol=xxx

// 客户端实现
<br>spring.dubbo.application.registries.transporter=xxx

<br>spring.dubbo.application.registries.server=xxx

<br>spring.dubbo.application.registries.client=xxx

<br>spring.dubbo.application.registries.cluster=xxx

<br>spring.dubbo.application.registries.group=xxx

<br>spring.dubbo.application.registries.version=xxx

// 注册中心请求超时时间(毫秒)
<br>spring.dubbo.application.registries.timeout=xxx

// 注册中心会话超时时间(毫秒)
<br>spring.dubbo.application.registries.session=xxx

// 动态注册中心列表存储文件
<br>spring.dubbo.application.registries.file=xxx

// 停止时等候完成通知时间
<br>spring.dubbo.application.registries.wait=xxx

// 启动时检查注册中心是否存在
<br>spring.dubbo.application.registries.check=xxx

// 在该注册中心上注册是动态的还是静态的服务
<br>spring.dubbo.application.registries.dynamic=xxx

// 在该注册中心上服务是否暴露
<br>spring.dubbo.application.registries.register=xxx

// 在该注册中心上服务是否引用
<br>spring.dubbo.application.registries.subscribe=xxx


## Dubbo 服务协议配置


// 服务协议
<br>spring.dubbo.application.protocol.name=xxx

// 服务IP地址(多网卡时使用)
<br>spring.dubbo.application.protocol.host=xxx

// 服务端口
<br>spring.dubbo.application.protocol.port=xxx

// 上下文路径
<br>spring.dubbo.application.protocol.contextpath=xxx

// 线程池类型
<br>spring.dubbo.application.protocol.threadpool=xxx

// 线程池大小(固定大小)
<br>spring.dubbo.application.protocol.threads=xxx

// IO线程池大小(固定大小)
<br>spring.dubbo.application.protocol.iothreads=xxx

// 线程池队列大小
<br>spring.dubbo.application.protocol.queues=xxx

// 最大接收连接数
<br>spring.dubbo.application.protocol.accepts=xxx

// 协议编码
<br>spring.dubbo.application.protocol.codec=xxx

// 序列化方式
<br>spring.dubbo.application.protocol.serialization=xxx

// 字符集
<br>spring.dubbo.application.protocol.charset=xxx

// 最大请求数据长度
<br>spring.dubbo.application.protocol.payload=xxx

// 缓存区大小
<br>spring.dubbo.application.protocol.buffer=xxx

// 心跳间隔
<br>spring.dubbo.application.protocol.heartbeat=xxx

// 访问日志
<br>spring.dubbo.application.protocol.accesslog=xxx

// 网络传输方式
<br>spring.dubbo.application.protocol.transporter=xxx

// 信息交换方式
<br>spring.dubbo.application.protocol.exchanger=xxx

// 信息线程模型派发方式
<br>spring.dubbo.application.protocol.dispatcher=xxx

// 对称网络组网方式
<br>spring.dubbo.application.protocol.networker=xxx

// 服务器端实现
<br>spring.dubbo.application.protocol.server=xxx

// 客户端实现
<br>spring.dubbo.application.protocol.client=xxx

// 支持的telnet命令,多个命令用逗号分隔
<br>spring.dubbo.application.protocol.telnet=xxx

// 命令行提示符
<br>spring.dubbo.application.protocol.prompt=xxx

// status检查
<br>spring.dubbo.application.protocol.status=xxx

// 是否注册
<br>spring.dubbo.application.protocol.status=xxx




================================================
FILE: springboot-dubbo-server/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>springboot</groupId>
    <artifactId>springboot-dubbo-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <!-- Spring Boot 启动父依赖 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
    </parent>

    <properties>
        <dubbo-spring-boot>1.0.0</dubbo-spring-boot>
    </properties>

    <dependencies>

        <!-- Spring Boot Dubbo 依赖 -->
        <dependency>
            <groupId>io.dubbo.springboot</groupId>
            <artifactId>spring-boot-starter-dubbo</artifactId>
            <version>${dubbo-spring-boot}</version>
        </dependency>

        <!-- Spring Boot Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- Spring Boot Test 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>
</project>


================================================
FILE: springboot-dubbo-server/src/main/java/org/spring/springboot/ServerApplication.java
================================================
package org.spring.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 * Created by bysocket on 16/4/26.
 */
// Spring Boot 应用的标识
@SpringBootApplication
public class ServerApplication {

    public static void main(String[] args) {
        // 程序启动入口
        // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件
        SpringApplication.run(ServerApplication.class,args);
    }
}


================================================
FILE: springboot-dubbo-server/src/main/java/org/spring/springboot/domain/City.java
================================================
package org.spring.springboot.domain;

import java.io.Serializable;

/**
 * 城市实体类
 *
 * Created by bysocket on 07/02/2017.
 */
public class City implements Serializable {

    private static final long serialVersionUID = -1L;

    /**
     * 城市编号
     */
    private Long id;

    /**
     * 省份编号
     */
    private Long provinceId;

    /**
     * 城市名称
     */
    private String cityName;

    /**
     * 描述
     */
    private String description;

    public City() {
    }

    public City(Long id, Long provinceId, String cityName, String description) {
        this.id = id;
        this.provinceId = provinceId;
        this.cityName = cityName;
        this.description = description;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(Long provinceId) {
        this.provinceId = provinceId;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}


================================================
FILE: springboot-dubbo-server/src/main/java/org/spring/springboot/dubbo/CityDubboService.java
================================================
package org.spring.springboot.dubbo;

import org.spring.springboot.domain.City;

/**
 * 城市业务 Dubbo 服务层
 *
 * Created by bysocket on 28/02/2017.
 */
public interface CityDubboService {

    /**
     * 根据城市名称,查询城市信息
     * @param cityName
     */
    City findCityByName(String cityName);
}


================================================
FILE: springboot-dubbo-server/src/main/java/org/spring/springboot/dubbo/impl/CityDubboServiceImpl.java
================================================
package org.spring.springboot.dubbo.impl;

import com.alibaba.dubbo.config.annotation.Service;
import org.spring.springboot.domain.City;
import org.spring.springboot.dubbo.CityDubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 城市业务 Dubbo 服务层实现层
 *
 * Created by bysocket on 28/02/2017.
 */
// 注册为 Dubbo 服务
@Service(version = "1.0.0")
public class CityDubboServiceImpl implements CityDubboService {

    public City findCityByName(String cityName) {
        return new City(1L,2L,"温岭","是我的故乡");
    }
}


================================================
FILE: springboot-dubbo-server/src/main/resources/application.properties
================================================
## Dubbo 服务提供者配置
spring.dubbo.application.name=provider
spring.dubbo.registry.address=zookeeper://127.0.0.1:2181
spring.dubbo.protocol.name=dubbo
spring.dubbo.protocol.port=20880
spring.dubbo.scan=org.spring.springboot.dubbo

================================================
FILE: springboot-elasticsearch/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>springboot</groupId>
    <artifactId>springboot-elasticsearch</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot-elasticsearch</name>

    <!-- Spring Boot 启动父依赖 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.1.RELEASE</version>
    </parent>

    <dependencies>

        <!-- Spring Boot Elasticsearch 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>

        <!-- Spring Boot Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>
</project>


================================================
FILE: springboot-elasticsearch/src/main/java/org/spring/springboot/Application.java
================================================
package org.spring.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 * Created by bysocket on 16/4/26.
 */
// Spring Boot 应用的标识
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        // 程序启动入口
        // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件
        SpringApplication.run(Application.class,args);
    }
}


================================================
FILE: springboot-elasticsearch/src/main/java/org/spring/springboot/controller/CityRestController.java
================================================
package org.spring.springboot.controller;

import org.spring.springboot.domain.City;
import org.spring.springboot.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 城市 Controller 实现 Restful HTTP 服务
 * <p>
 * Created by bysocket on 03/05/2017.
 */
@RestController
public class CityRestController {

    @Autowired
    private CityService cityService;

    @RequestMapping(value = "/api/city", method = RequestMethod.POST)
    public Long createCity(@RequestBody City city) {
        return cityService.saveCity(city);
    }

    @RequestMapping(value = "/api/city/search", method = RequestMethod.GET)
    public List<City> searchCity(@RequestParam(value = "pageNumber") Integer pageNumber,
                                 @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                 @RequestParam(value = "searchContent") String searchContent) {
        return cityService.searchCity(pageNumber,pageSize,searchContent);
    }
}


================================================
FILE: springboot-elasticsearch/src/main/java/org/spring/springboot/domain/City.java
================================================
package org.spring.springboot.domain;

import org.springframework.data.elasticsearch.annotations.Document;

import java.io.Serializable;

/**
 * 城市实体类
 *
 * Created by bysocket on 03/05/2017.
 */
@Document(indexName = "cityindex", type = "city")
public class City implements Serializable{

    private static final long serialVersionUID = -1L;

    /**
     * 城市编号
     */
    private Long id;

    /**
     * 省份编号
     */
    private Long provinceid;

    /**
     * 城市名称
     */
    private String cityname;

    /**
     * 描述
     */
    private String description;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getProvinceid() {
        return provinceid;
    }

    public void setProvinceid(Long provinceid) {
        this.provinceid = provinceid;
    }

    public String getCityname() {
        return cityname;
    }

    public void setCityname(String cityname) {
        this.cityname = cityname;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}


================================================
FILE: springboot-elasticsearch/src/main/java/org/spring/springboot/repository/CityRepository.java
================================================
package org.spring.springboot.repository;

import org.spring.springboot.domain.City;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

/**
 * Created by bysocket on 17/05/2017.
 */
@Repository
public interface CityRepository extends ElasticsearchRepository<City,Long> {


}


================================================
FILE: springboot-elasticsearch/src/main/java/org/spring/springboot/service/CityService.java
================================================

package org.spring.springboot.service;

import org.spring.springboot.domain.City;
import java.util.List;

public interface CityService {

    /**
     * 新增城市信息
     *
     * @param city
     * @return
     */
    Long saveCity(City city);

    /**
     * 根据关键词,function score query 权重分分页查询
     *
     * @param pageNumber
     * @param pageSize
     * @param searchContent
     * @return
     */
    List<City> searchCity(Integer pageNumber, Integer pageSize, String searchContent);
}

================================================
FILE: springboot-elasticsearch/src/main/java/org/spring/springboot/service/impl/CityESServiceImpl.java
================================================
package org.spring.springboot.service.impl;

import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spring.springboot.domain.City;
import org.spring.springboot.repository.CityRepository;
import org.spring.springboot.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 城市 ES 业务逻辑实现类
 *
 * Created by bysocket on 07/02/2017.
 */
@Service
public class CityESServiceImpl implements CityService {

    private static final Logger LOGGER = LoggerFactory.getLogger(CityESServiceImpl.class);

    @Autowired
    CityRepository cityRepository;

    @Override
    public Long saveCity(City city) {

        City cityResult = cityRepository.save(city);
        return cityResult.getId();
    }

    @Override
    public List<City> searchCity(Integer pageNumber,
                                 Integer pageSize,
                                 String searchContent) {
        // 分页参数
        Pageable pageable = new PageRequest(pageNumber, pageSize);

        // Function Score Query
        FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery()
                .add(QueryBuilders.boolQuery().should(QueryBuilders.matchQuery("cityname", searchContent)),
                    ScoreFunctionBuilders.weightFactorFunction(1000))
                .add(QueryBuilders.boolQuery().should(QueryBuilders.matchQuery("description", searchContent)),
                        ScoreFunctionBuilders.weightFactorFunction(100));

        // 创建搜索 DSL 查询
        SearchQuery searchQuery = new NativeSearchQueryBuilder()
                .withPageable(pageable)
                .withQuery(functionScoreQueryBuilder).build();

        LOGGER.info("\n searchCity(): searchContent [" + searchContent + "] \n DSL  = \n " + searchQuery.getQuery().toString());

        Page<City> searchPageResults = cityRepository.search(searchQuery);
        return searchPageResults.getContent();
    }

}


================================================
FILE: springboot-elasticsearch/src/main/resources/application.properties
================================================
# ES
spring.data.elasticsearch.repositories.enabled = true
spring.data.elasticsearch.cluster-nodes = 127.0.0.1:9300

================================================
FILE: springboot-freemarker/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>springboot</groupId>
    <artifactId>springboot-freemarker</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot-freemarker</name>

    <!-- Spring Boot 启动父依赖 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
    </parent>

    <properties>
        <mybatis-spring-boot>1.2.0</mybatis-spring-boot>
        <mysql-connector>5.1.39</mysql-connector>
    </properties>

    <dependencies>
        <!-- Spring Boot Freemarker 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-freemarker</artifactId>
        </dependency>

        <!-- Spring Boot Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- Spring Boot Test 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Spring Boot Mybatis 依赖 -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>${mybatis-spring-boot}</version>
        </dependency>

        <!-- MySQL 连接驱动依赖 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql-connector}</version>
        </dependency>

        <!-- Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>
</project>


================================================
FILE: springboot-freemarker/src/main/java/org/spring/springboot/Application.java
================================================
package org.spring.springboot;

import org.mybatis.spring.annotation.MapperScan;
import org.spring.springboot.dao.CityDao;
import org.spring.springboot.domain.City;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 * Created by bysocket on 16/4/26.
 */
// Spring Boot 应用的标识
@SpringBootApplication
// mapper 接口类扫描包配置
@MapperScan("org.spring.springboot.dao")
public class Application {

    public static void main(String[] args) {
        // 程序启动入口
        // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件
        SpringApplication.run(Application.class,args);
    }
}


================================================
FILE: springboot-freemarker/src/main/java/org/spring/springboot/controller/CityController.java
================================================
package org.spring.springboot.controller;

import org.spring.springboot.domain.City;
import org.spring.springboot.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 城市 Controller 实现 Restful HTTP 服务
 * <p>
 * Created by bysocket on 07/02/2017.
 */
@Controller
public class CityController {

    @Autowired
    private CityService cityService;

    @RequestMapping(value = "/api/city/{id}", method = RequestMethod.GET)
    public String findOneCity(Model model, @PathVariable("id") Long id) {
        model.addAttribute("city", cityService.findCityById(id));
        return "city";
    }

    @RequestMapping(value = "/api/city", method = RequestMethod.GET)
    public String findAllCity(Model model) {
        List<City> cityList = cityService.findAllCity();
        model.addAttribute("cityList",cityList);
        return "cityList";
    }
}


================================================
FILE: springboot-freemarker/src/main/java/org/spring/springboot/dao/CityDao.java
================================================
package org.spring.springboot.dao;

import org.apache.ibatis.annotations.Param;
import org.spring.springboot.domain.City;

import java.util.List;

/**
 * 城市 DAO 接口类
 *
 * Created by bysocket on 07/02/2017.
 */
public interface CityDao {

    /**
     * 获取城市信息列表
     *
     * @return
     */
    List<City> findAllCity();

    /**
     * 根据城市 ID,获取城市信息
     *
     * @param id
     * @return
     */
    City findById(@Param("id") Long id);

    Long saveCity(City city);

    Long updateCity(City city);

    Long deleteCity(Long id);
}


================================================
FILE: springboot-freemarker/src/main/java/org/spring/springboot/domain/City.java
================================================
package org.spring.springboot.domain;

/**
 * 城市实体类
 *
 * Created by bysocket on 07/02/2017.
 */
public class City {

    /**
     * 城市编号
     */
    private Long id;

    /**
     * 省份编号
     */
    private Long provinceId;

    /**
     * 城市名称
     */
    private String cityName;

    /**
     * 描述
     */
    private String description;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(Long provinceId) {
        this.provinceId = provinceId;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}


================================================
FILE: springboot-freemarker/src/main/java/org/spring/springboot/service/CityService.java
================================================
package org.spring.springboot.service;

import org.spring.springboot.domain.City;

import java.util.List;

/**
 * 城市业务逻辑接口类
 *
 * Created by bysocket on 07/02/2017.
 */
public interface CityService {

    /**
     * 获取城市信息列表
     *
     * @return
     */
    List<City> findAllCity();

    /**
     * 根据城市 ID,查询城市信息
     *
     * @param id
     * @return
     */
    City findCityById(Long id);

    /**
     * 新增城市信息
     *
     * @param city
     * @return
     */
    Long saveCity(City city);

    /**
     * 更新城市信息
     *
     * @param city
     * @return
     */
    Long updateCity(City city);

    /**
     * 根据城市 ID,删除城市信息
     *
     * @param id
     * @return
     */
    Long deleteCity(Long id);
}


================================================
FILE: springboot-freemarker/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java
================================================
package org.spring.springboot.service.impl;

import org.spring.springboot.dao.CityDao;
import org.spring.springboot.domain.City;
import org.spring.springboot.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 城市业务逻辑实现类
 *
 * Created by bysocket on 07/02/2017.
 */
@Service
public class CityServiceImpl implements CityService {

    @Autowired
    private CityDao cityDao;

    public List<City> findAllCity(){
        return cityDao.findAllCity();
    }

    public City findCityById(Long id) {
        return cityDao.findById(id);
    }

    @Override
    public Long saveCity(City city) {
        return cityDao.saveCity(city);
    }

    @Override
    public Long updateCity(City city) {
        return cityDao.updateCity(city);
    }

    @Override
    public Long deleteCity(Long id) {
        return cityDao.deleteCity(id);
    }

}


================================================
FILE: springboot-freemarker/src/main/resources/application.properties
================================================
## 数据源配置
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/springbootdb?useUnicode=true&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

## Mybatis 配置
mybatis.typeAliasesPackage=org.spring.springboot.domain
mybatis.mapperLocations=classpath:mapper/*.xml

## Freemarker 配置
## 文件配置路径
spring.freemarker.template-loader-path=classpath:/web/
spring.freemarker.cache=false
spring.freemarker.charset=UTF-8
spring.freemarker.check-template-location=true
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=true
spring.freemarker.expose-session-attributes=true
spring.freemarker.request-context-attribute=request
spring.freemarker.suffix=.ftl


================================================
FILE: springboot-freemarker/src/main/resources/mapper/CityMapper.xml
================================================
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.spring.springboot.dao.CityDao">
	<resultMap id="BaseResultMap" type="org.spring.springboot.domain.City">
		<result column="id" property="id" />
		<result column="province_id" property="provinceId" />
		<result column="city_name" property="cityName" />
		<result column="description" property="description" />
	</resultMap>

	<sql id="Base_Column_List">
		id, province_id, city_name, description
	</sql>

	<select id="findById" resultMap="BaseResultMap" parameterType="java.lang.Long">
		select
		<include refid="Base_Column_List" />
		from city
		where id = #{id}
	</select>

	<select id="findAllCity" resultMap="BaseResultMap" >
		select
		<include refid="Base_Column_List" />
		from city
	</select>

	<insert id="saveCity" parameterType="City" useGeneratedKeys="true" keyProperty="id">
		insert into
			city(id,province_id,city_name,description)
		values
			(#{id},#{provinceId},#{cityName},#{description})
	</insert>

	<update id="updateCity" parameterType="City">
		update
			city
		set
		<if test="provinceId!=null">
			province_id = #{provinceId},
		</if>
		<if test="cityName!=null">
			city_name = #{cityName},
		</if>
		<if test="description!=null">
			description = #{description}
		</if>
		where
			id = #{id}
	</update>

	<delete id="deleteCity" parameterType="java.lang.Long">
		delete from
			city
		where
			id = #{id}
	</delete>
</mapper>


================================================
FILE: springboot-freemarker/src/main/resources/web/city.ftl
================================================
<!DOCTYPE html>

<html lang="en">

<body>
City: ${city.cityName}! <br>
Q:Why I like? <br>
A:${city.description}!
</body>

</html>

================================================
FILE: springboot-freemarker/src/main/resources/web/cityList.ftl
================================================
<!DOCTYPE html>

<html lang="en">

<body>
<#list cityList as city>

City: ${city.cityName}! <br>
Q:Why I like? <br>
A:${city.description}!

</#list>
</body>

</html>

================================================
FILE: springboot-hbase/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>springboot</groupId>
    <artifactId>springboot-hbase</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot-hbase</name>

    <!-- Spring Boot 启动父依赖 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.6.RELEASE</version>
    </parent>

    <properties>
        <hbase-spring-boot>1.0.0.RELEASE</hbase-spring-boot>
    </properties>

    <dependencies>

        <!-- Spring Boot Web 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- Spring Boot Test 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Spring Boot HBase 依赖 -->
        <dependency>
            <groupId>com.spring4all</groupId>
            <artifactId>spring-boot-starter-hbase</artifactId>
            <version>${hbase-spring-boot}</version>
        </dependency>

        <!-- Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>
</project>


================================================
FILE: springboot-hbase/src/main/java/org/spring/springboot/Application.java
================================================
package org.spring.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Spring Boot 应用启动类
 *
 * Created by bysocket on 16/4/26.
 */
// Spring Boot 应用的标识
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        // 程序启动入口
        // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件
        SpringApplication.run(Application.class,args);
    }
}


Download .txt
gitextract_8i_wvbh2/

├── .gitignore
├── 2-x-spring-boot-groovy/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── filter/
│           │               │   └── RouteRuleFilter.java
│           │               └── web/
│           │                   └── GroovyScriptController.java
│           └── resources/
│               └── application.properties
├── 2-x-spring-boot-webflux-handling-errors/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── error/
│           │               │   ├── GlobalErrorAttributes.java
│           │               │   ├── GlobalErrorWebExceptionHandler.java
│           │               │   └── GlobalException.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── router/
│           │                   └── CityRouter.java
│           └── resources/
│               └── application.properties
├── LICENSE
├── README.md
├── chapter-1-spring-boot-quickstart/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── demo/
│       │   │       └── springboot/
│       │   │           ├── QuickStartApplication.java
│       │   │           └── web/
│       │   │               ├── HelloBookController.java
│       │   │               └── HelloController.java
│       │   └── resources/
│       │       └── application.properties
│       └── test/
│           ├── java/
│           │   └── demo/
│           │       └── springboot/
│           │           └── QuickStartApplicationTests.java
│           └── resources/
│               └── application.properties
├── chapter-2-spring-boot-config/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── demo/
│       │   │       └── springboot/
│       │   │           ├── ConfigApplication.java
│       │   │           ├── config/
│       │   │           │   ├── BookComponent.java
│       │   │           │   └── BookProperties.java
│       │   │           └── web/
│       │   │               └── HelloBookController.java
│       │   └── resources/
│       │       ├── application-dev.properties
│       │       ├── application-prod.properties
│       │       ├── application.properties
│       │       └── application.yml
│       └── test/
│           └── java/
│               └── demo/
│                   └── springboot/
│                       └── ConfigApplicationTests.java
├── chapter-3-spring-boot-web/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── demo/
│       │   │       └── springboot/
│       │   │           ├── WebApplication.java
│       │   │           ├── domain/
│       │   │           │   └── Book.java
│       │   │           ├── service/
│       │   │           │   ├── BookService.java
│       │   │           │   └── impl/
│       │   │           │       └── BookServiceImpl.java
│       │   │           └── web/
│       │   │               └── BookController.java
│       │   └── resources/
│       │       └── application.properties
│       └── test/
│           ├── java/
│           │   └── demo/
│           │       └── springboot/
│           │           ├── WebApplicationTests.java
│           │           └── web/
│           │               └── BookControllerTest.java
│           └── resources/
│               └── application.properties
├── chapter-4-spring-boot-validating-form-input/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── spring/
│       │   │       └── boot/
│       │   │           └── core/
│       │   │               ├── ValidatingFormInputApplication.java
│       │   │               ├── domain/
│       │   │               │   ├── User.java
│       │   │               │   └── UserRepository.java
│       │   │               ├── service/
│       │   │               │   ├── UserService.java
│       │   │               │   └── impl/
│       │   │               │       └── UserServiceImpl.java
│       │   │               └── web/
│       │   │                   └── UserController.java
│       │   └── resources/
│       │       ├── application.properties
│       │       ├── static/
│       │       │   └── css/
│       │       │       └── default.css
│       │       └── templates/
│       │           ├── userForm.html
│       │           └── userList.html
│       └── test/
│           ├── java/
│           │   └── spring/
│           │       └── boot/
│           │           └── core/
│           │               ├── ValidatingFormInputApplicationTests.java
│           │               └── web/
│           │                   └── UserControllerTest.java
│           └── resources/
│               ├── application.properties
│               ├── static/
│               │   └── css/
│               │       └── default.css
│               └── templates/
│                   ├── userForm.html
│                   └── userList.html
├── chapter-4-spring-boot-web-thymeleaf/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── demo/
│       │   │       └── springboot/
│       │   │           ├── WebApplication.java
│       │   │           ├── domain/
│       │   │           │   └── Book.java
│       │   │           ├── service/
│       │   │           │   ├── BookService.java
│       │   │           │   └── impl/
│       │   │           │       └── BookServiceImpl.java
│       │   │           └── web/
│       │   │               └── BookController.java
│       │   └── resources/
│       │       ├── application.properties
│       │       ├── static/
│       │       │   └── css/
│       │       │       └── default.css
│       │       └── templates/
│       │           ├── bookForm.html
│       │           └── bookList.html
│       └── test/
│           └── java/
│               └── demo/
│                   └── springboot/
│                       └── WebApplicationTests.java
├── chapter-5-spring-boot-data-jpa/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── demo/
│       │   │       └── springboot/
│       │   │           ├── WebApplication.java
│       │   │           ├── domain/
│       │   │           │   ├── Book.java
│       │   │           │   └── BookRepository.java
│       │   │           ├── service/
│       │   │           │   ├── BookService.java
│       │   │           │   └── impl/
│       │   │           │       └── BookServiceImpl.java
│       │   │           └── web/
│       │   │               └── BookController.java
│       │   └── resources/
│       │       ├── application.properties
│       │       ├── static/
│       │       │   └── css/
│       │       │       └── default.css
│       │       └── templates/
│       │           ├── bookForm.html
│       │           └── bookList.html
│       └── test/
│           └── java/
│               └── demo/
│                   └── springboot/
│                       └── WebApplicationTests.java
├── chapter-5-spring-boot-paging-sorting/
│   ├── 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
│       └── test/
│           └── java/
│               └── spring/
│                   └── boot/
│                       └── core/
│                           └── PagingSortingApplicationTests.java
├── pom.xml
├── spring-data-elasticsearch-crud/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── repository/
│           │               │   └── CityRepository.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityESServiceImpl.java
│           └── resources/
│               └── application.properties
├── spring-data-elasticsearch-query/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── repository/
│           │               │   └── CityRepository.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityESServiceImpl.java
│           └── resources/
│               └── application.properties
├── springboot-configuration/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   └── java/
│       │       └── org/
│       │           └── spring/
│       │               └── springboot/
│       │                   ├── Application.java
│       │                   └── config/
│       │                       └── MessageConfiguration.java
│       └── test/
│           └── java/
│               └── org/
│                   └── spring/
│                       └── springboot/
│                           └── config/
│                               └── MessageConfigurationTest.java
├── springboot-dubbo-client/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── ClientApplication.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── dubbo/
│           │                   ├── CityDubboConsumerService.java
│           │                   └── CityDubboService.java
│           └── resources/
│               └── application.properties
├── springboot-dubbo-server/
│   ├── DubboProperties.md
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── ServerApplication.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── dubbo/
│           │                   ├── CityDubboService.java
│           │                   └── impl/
│           │                       └── CityDubboServiceImpl.java
│           └── resources/
│               └── application.properties
├── springboot-elasticsearch/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── repository/
│           │               │   └── CityRepository.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityESServiceImpl.java
│           └── resources/
│               └── application.properties
├── springboot-freemarker/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityController.java
│           │               ├── dao/
│           │               │   └── CityDao.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityServiceImpl.java
│           └── resources/
│               ├── application.properties
│               ├── mapper/
│               │   └── CityMapper.xml
│               └── web/
│                   ├── city.ftl
│                   └── cityList.ftl
├── springboot-hbase/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── dao/
│           │               │   └── CityRowMapper.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityServiceImpl.java
│           └── resources/
│               └── application.properties
├── springboot-helloworld/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   └── java/
│       │       └── org/
│       │           └── spring/
│       │               └── springboot/
│       │                   ├── Application.java
│       │                   └── web/
│       │                       └── HelloWorldController.java
│       └── test/
│           └── java/
│               └── org/
│                   └── spring/
│                       └── springboot/
│                           └── web/
│                               └── HelloWorldControllerTest.java
├── springboot-mybatis/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── dao/
│           │               │   └── CityDao.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityServiceImpl.java
│           └── resources/
│               ├── application.properties
│               └── mapper/
│                   └── CityMapper.xml
├── springboot-mybatis-annotation/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── dao/
│           │               │   └── CityDao.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityServiceImpl.java
│           └── resources/
│               └── application.properties
├── springboot-mybatis-mutil-datasource/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── config/
│           │               │   └── ds/
│           │               │       ├── ClusterDataSourceConfig.java
│           │               │       └── MasterDataSourceConfig.java
│           │               ├── controller/
│           │               │   └── UserRestController.java
│           │               ├── dao/
│           │               │   ├── cluster/
│           │               │   │   └── CityDao.java
│           │               │   └── master/
│           │               │       └── UserDao.java
│           │               ├── domain/
│           │               │   ├── City.java
│           │               │   └── User.java
│           │               └── service/
│           │                   ├── UserService.java
│           │                   └── impl/
│           │                       └── UserServiceImpl.java
│           └── resources/
│               ├── application.properties
│               └── mapper/
│                   ├── cluster/
│                   │   └── CityMapper.xml
│                   └── master/
│                       └── UserMapper.xml
├── springboot-mybatis-redis/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── dao/
│           │               │   └── CityDao.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityServiceImpl.java
│           └── resources/
│               ├── application.properties
│               └── mapper/
│                   └── CityMapper.xml
├── springboot-mybatis-redis-annotation/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── org/
│       │   │       └── spring/
│       │   │           └── springboot/
│       │   │               ├── Application.java
│       │   │               ├── domain/
│       │   │               │   └── City.java
│       │   │               └── service/
│       │   │                   ├── CityService.java
│       │   │                   └── impl/
│       │   │                       └── CityServiceImpl.java
│       │   └── resources/
│       │       └── application.properties
│       └── test/
│           └── org/
│               └── spring/
│                   └── springboot/
│                       └── ApplicationTests.java
├── springboot-properties/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── org/
│       │   │       └── spring/
│       │   │           └── springboot/
│       │   │               ├── Application.java
│       │   │               ├── property/
│       │   │               │   ├── HomeProperties.java
│       │   │               │   └── UserProperties.java
│       │   │               └── web/
│       │   │                   └── HelloWorldController.java
│       │   └── resources/
│       │       ├── application-dev.properties
│       │       ├── application-prod.properties
│       │       └── application.properties
│       └── test/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── property/
│           │               │   ├── HomeProperties1.java
│           │               │   └── PropertiesTest.java
│           │               └── web/
│           │                   └── HelloWorldControllerTest.java
│           └── resouorces/
│               └── application.yml
├── springboot-restful/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── controller/
│           │               │   └── CityRestController.java
│           │               ├── dao/
│           │               │   └── CityDao.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── service/
│           │                   ├── CityService.java
│           │                   └── impl/
│           │                       └── CityServiceImpl.java
│           └── resources/
│               ├── application.properties
│               └── mapper/
│                   └── CityMapper.xml
├── springboot-validation-over-json/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   └── java/
│       │       └── org/
│       │           └── spring/
│       │               └── springboot/
│       │                   ├── Application.java
│       │                   ├── constant/
│       │                   │   └── CityErrorInfoEnum.java
│       │                   ├── result/
│       │                   │   ├── ErrorInfoInterface.java
│       │                   │   ├── GlobalErrorInfoEnum.java
│       │                   │   ├── GlobalErrorInfoException.java
│       │                   │   ├── GlobalErrorInfoHandler.java
│       │                   │   └── ResultBody.java
│       │                   └── web/
│       │                       ├── City.java
│       │                       └── ErrorJsonController.java
│       └── test/
│           └── java/
│               └── org/
│                   └── spring/
│                       └── springboot/
│                           └── web/
│                               └── ErrorJsonControllerTest.java
├── springboot-webflux-1-quickstart/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── router/
│           │                   └── CityRouter.java
│           └── resources/
│               └── application.properties
├── springboot-webflux-10-book-manage-sys/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── demo/
│           │       └── springboot/
│           │           ├── WebApplication.java
│           │           ├── dao/
│           │           │   └── CityRepository.java
│           │           ├── domain/
│           │           │   └── City.java
│           │           ├── service/
│           │           │   ├── CityService.java
│           │           │   └── impl/
│           │           │       └── CityServiceImpl.java
│           │           └── web/
│           │               └── CityController.java
│           └── resources/
│               ├── application.properties
│               ├── static/
│               │   └── css/
│               │       └── default.css
│               └── templates/
│                   ├── cityForm.html
│                   └── cityList.html
├── springboot-webflux-2-restful/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── dao/
│           │               │   └── CityRepository.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── webflux/
│           │                   └── controller/
│           │                       └── CityWebFluxController.java
│           └── resources/
│               └── application.properties
├── springboot-webflux-3-mongodb/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── dao/
│           │               │   └── CityRepository.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── webflux/
│           │                   └── controller/
│           │                       └── CityWebFluxController.java
│           └── resources/
│               └── application.properties
├── springboot-webflux-4-thymeleaf/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── dao/
│           │               │   └── CityRepository.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── webflux/
│           │                   └── controller/
│           │                       └── CityWebFluxController.java
│           └── resources/
│               ├── application.properties
│               └── templates/
│                   ├── cityList.html
│                   └── hello.html
├── springboot-webflux-5-thymeleaf-mongodb/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── dao/
│           │               │   └── CityRepository.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── webflux/
│           │                   └── controller/
│           │                       └── CityWebFluxController.java
│           └── resources/
│               ├── application.properties
│               └── templates/
│                   ├── city.html
│                   └── cityList.html
├── springboot-webflux-6-redis/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               └── webflux/
│           │                   └── controller/
│           │                       ├── CityWebFluxController.java
│           │                       └── CityWebFluxReactiveController.java
│           └── resources/
│               └── application.properties
├── springboot-webflux-7-redis-cache/
│   ├── pom.xml
│   └── src/
│       └── main/
│           ├── java/
│           │   └── org/
│           │       └── spring/
│           │           └── springboot/
│           │               ├── Application.java
│           │               ├── dao/
│           │               │   └── CityRepository.java
│           │               ├── domain/
│           │               │   └── City.java
│           │               ├── handler/
│           │               │   └── CityHandler.java
│           │               └── webflux/
│           │                   └── controller/
│           │                       └── CityWebFluxController.java
│           └── resources/
│               └── application.properties
├── springboot-webflux-8-websocket/
│   ├── pom.xml
│   └── src/
│       ├── main/
│       │   ├── java/
│       │   │   └── org/
│       │   │       └── spring/
│       │   │           └── springboot/
│       │   │               ├── Application.java
│       │   │               ├── config/
│       │   │               │   └── WebSocketConfiguration.java
│       │   │               └── handler/
│       │   │                   └── EchoHandler.java
│       │   └── resources/
│       │       ├── application.properties
│       │       └── websocket-client.html
│       └── test/
│           └── java/
│               └── WSClient.java
└── springboot-webflux-9-test/
    ├── pom.xml
    └── src/
        ├── main/
        │   ├── java/
        │   │   └── org/
        │   │       └── spring/
        │   │           └── springboot/
        │   │               ├── Application.java
        │   │               ├── dao/
        │   │               │   └── CityRepository.java
        │   │               ├── domain/
        │   │               │   └── City.java
        │   │               ├── handler/
        │   │               │   └── CityHandler.java
        │   │               └── webflux/
        │   │                   └── controller/
        │   │                       └── CityWebFluxController.java
        │   └── resources/
        │       └── application.properties
        └── test/
            └── java/
                └── org/
                    └── spring/
                        └── springboot/
                            └── handler/
                                └── CityHandlerTest.java
Download .txt
SYMBOL INDEX (901 symbols across 201 files)

FILE: 2-x-spring-boot-groovy/src/main/java/org/spring/springboot/Application.java
  class Application (line 11) | @SpringBootApplication
    method main (line 14) | public static void main(String[] args) {

FILE: 2-x-spring-boot-groovy/src/main/java/org/spring/springboot/filter/RouteRuleFilter.java
  class RouteRuleFilter (line 10) | @Component
    method filter (line 13) | public Map<String,Object> filter(Map<String,Object> input) {

FILE: 2-x-spring-boot-groovy/src/main/java/org/spring/springboot/web/GroovyScriptController.java
  class GroovyScriptController (line 11) | @RestController
    method filter (line 15) | @RequestMapping(value = "/filter", method = RequestMethod.GET)
    method main (line 28) | public static void main(String[] args) {

FILE: 2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/Application.java
  class Application (line 11) | @SpringBootApplication
    method main (line 14) | public static void main(String[] args) {

FILE: 2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/error/GlobalErrorAttributes.java
  class GlobalErrorAttributes (line 9) | @Component
    method getErrorAttributes (line 12) | @Override

FILE: 2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/error/GlobalErrorWebExceptionHandler.java
  class GlobalErrorWebExceptionHandler (line 22) | @Component
    method GlobalErrorWebExceptionHandler (line 26) | public GlobalErrorWebExceptionHandler(GlobalErrorAttributes g, Applica...
    method getRoutingFunction (line 33) | @Override
    method renderErrorResponse (line 38) | private Mono<ServerResponse> renderErrorResponse(final ServerRequest r...

FILE: 2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/error/GlobalException.java
  class GlobalException (line 6) | public class GlobalException extends ResponseStatusException {
    method GlobalException (line 8) | public GlobalException(HttpStatus status, String message) {
    method GlobalException (line 12) | public GlobalException(HttpStatus status, String message, Throwable e) {

FILE: 2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/handler/CityHandler.java
  class CityHandler (line 12) | @Component
    method helloCity (line 15) | public Mono<ServerResponse> helloCity(ServerRequest request) {
    method sayHelloCity (line 19) | private Mono<String> sayHelloCity(ServerRequest request) {

FILE: 2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/router/CityRouter.java
  class CityRouter (line 12) | @Configuration
    method routeCity (line 15) | @Bean

FILE: chapter-1-spring-boot-quickstart/src/main/java/demo/springboot/QuickStartApplication.java
  class QuickStartApplication (line 11) | @SpringBootApplication
    method main (line 13) | public static void main(String[] args) {

FILE: chapter-1-spring-boot-quickstart/src/main/java/demo/springboot/web/HelloBookController.java
  class HelloBookController (line 12) | @RestController
    method sayHello (line 15) | @RequestMapping(value = "/book/hello",method = RequestMethod.GET)

FILE: chapter-1-spring-boot-quickstart/src/main/java/demo/springboot/web/HelloController.java
  class HelloController (line 13) | @Controller
    method sayHello (line 16) | @RequestMapping(value = "/hello",method = RequestMethod.GET)

FILE: chapter-1-spring-boot-quickstart/src/test/java/demo/springboot/QuickStartApplicationTests.java
  class QuickStartApplicationTests (line 18) | @RunWith(SpringRunner.class)
    method requestHello_thenStatus200_and_outputHello (line 28) | @Test

FILE: chapter-2-spring-boot-config/src/main/java/demo/springboot/ConfigApplication.java
  class ConfigApplication (line 12) | @EnableSwagger2Doc // 开启 Swagger
    method main (line 15) | public static void main(String[] args) {

FILE: chapter-2-spring-boot-config/src/main/java/demo/springboot/config/BookComponent.java
  class BookComponent (line 14) | @Component
    method getName (line 31) | public String getName() {
    method setName (line 35) | public void setName(String name) {
    method getWriter (line 39) | public String getWriter() {
    method setWriter (line 43) | public void setWriter(String writer) {

FILE: chapter-2-spring-boot-config/src/main/java/demo/springboot/config/BookProperties.java
  class BookProperties (line 11) | @Component
    method getName (line 26) | public String getName() {
    method setName (line 30) | public void setName(String name) {
    method getWriter (line 34) | public String getWriter() {
    method setWriter (line 38) | public void setWriter(String writer) {

FILE: chapter-2-spring-boot-config/src/main/java/demo/springboot/web/HelloBookController.java
  class HelloBookController (line 13) | @RestController
    method sayHello (line 19) | @GetMapping("/book/hello")

FILE: chapter-2-spring-boot-config/src/test/java/demo/springboot/ConfigApplicationTests.java
  class ConfigApplicationTests (line 12) | @RunWith(SpringRunner.class)
    method testBookProperties (line 22) | @Test
    method testBookComponent (line 28) | @Test

FILE: chapter-3-spring-boot-web/src/main/java/demo/springboot/WebApplication.java
  class WebApplication (line 11) | @SpringBootApplication
    method main (line 13) | public static void main(String[] args) {

FILE: chapter-3-spring-boot-web/src/main/java/demo/springboot/domain/Book.java
  class Book (line 10) | public class Book implements Serializable {
    method getId (line 32) | public Long getId() {
    method setId (line 36) | public void setId(Long id) {
    method getName (line 40) | public String getName() {
    method setName (line 44) | public void setName(String name) {
    method getWriter (line 48) | public String getWriter() {
    method setWriter (line 52) | public void setWriter(String writer) {
    method getIntroduction (line 56) | public String getIntroduction() {
    method setIntroduction (line 60) | public void setIntroduction(String introduction) {
    method Book (line 64) | public Book(Long id, String name, String writer, String introduction) {
    method Book (line 71) | public Book(Long id, String name) {
    method Book (line 76) | public Book(String name) {
    method Book (line 80) | public Book() {

FILE: chapter-3-spring-boot-web/src/main/java/demo/springboot/service/BookService.java
  type BookService (line 12) | public interface BookService {
    method findAll (line 16) | List<Book> findAll();
    method insertByBook (line 23) | Book insertByBook(Book book);
    method update (line 30) | Book update(Book book);
    method delete (line 37) | Book delete(Long id);
    method findById (line 44) | Book findById(Long id);
    method exists (line 51) | boolean exists(Book book);
    method findByName (line 58) | Book findByName(String name);

FILE: chapter-3-spring-boot-web/src/main/java/demo/springboot/service/impl/BookServiceImpl.java
  class BookServiceImpl (line 22) | @Service
    method findAll (line 40) | @Override
    method insertByBook (line 45) | @Override
    method update (line 52) | @Override
    method delete (line 58) | @Override
    method findById (line 63) | @Override
    method exists (line 68) | @Override
    method findByName (line 73) | @Override

FILE: chapter-3-spring-boot-web/src/main/java/demo/springboot/web/BookController.java
  class BookController (line 21) | @RestController
    method getBookList (line 36) | @RequestMapping(method = RequestMethod.GET)
    method getBook (line 45) | @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    method postBook (line 55) | @RequestMapping(value = "/create", method = RequestMethod.POST)
    method putBook (line 76) | @RequestMapping(value = "/update", method = RequestMethod.PUT)
    method deleteBook (line 85) | @RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)

FILE: chapter-3-spring-boot-web/src/test/java/demo/springboot/WebApplicationTests.java
  class WebApplicationTests (line 8) | @RunWith(SpringRunner.class)
    method contextLoads (line 12) | @Test

FILE: chapter-3-spring-boot-web/src/test/java/demo/springboot/web/BookControllerTest.java
  class BookControllerTest (line 29) | @RunWith(SpringRunner.class)
    method init (line 43) | @Before
    method getBookList (line 53) | @Test
    method test_create_book_success (line 64) | @Test
    method test_create_book_fail_404_not_found (line 81) | @Test
    method test_get_book_success (line 95) | @Test
    method test_get_by_id_fail_null_not_found (line 112) | @Test
    method test_update_book_success (line 125) | @Test
    method test_update_book_fail_not_found (line 140) | @Test
    method test_delete_book_success (line 156) | @Test
    method test_delete_book_fail_404_not_found (line 169) | @Test
    method asJsonString (line 181) | public static String asJsonString(final Object obj) {
    method createOneBook (line 190) | private Book createOneBook() {

FILE: chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/ValidatingFormInputApplication.java
  class ValidatingFormInputApplication (line 12) | @SpringBootApplication
    method main (line 21) | public static void main(String[] args) {
    method run (line 25) | @Override

FILE: chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/domain/User.java
  class User (line 19) | @Entity
    method getId (line 50) | public Long getId() {
    method setId (line 54) | public void setId(Long id) {
    method getName (line 58) | public String getName() {
    method setName (line 62) | public void setName(String name) {
    method getAge (line 66) | public Integer getAge() {
    method setAge (line 70) | public void setAge(Integer age) {
    method getBirthday (line 74) | public String getBirthday() {
    method setBirthday (line 78) | public void setBirthday(String birthday) {
    method User (line 83) | public User(String name, Integer age, String birthday) {
    method User (line 89) | public User() {}
    method toString (line 91) | @Override

FILE: chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/domain/UserRepository.java
  type UserRepository (line 10) | public interface UserRepository extends JpaRepository<User, Long> {

FILE: chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/service/UserService.java
  type UserService (line 13) | public interface UserService {
    method findAll (line 15) | List<User> findAll();
    method insertByUser (line 17) | User insertByUser(User user);
    method update (line 19) | User update(User user);
    method delete (line 21) | User delete(Long id);
    method findById (line 23) | User findById(Long id);

FILE: chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/service/impl/UserServiceImpl.java
  class UserServiceImpl (line 18) | @Service
    method findAll (line 26) | @Override
    method insertByUser (line 31) | @Override
    method update (line 37) | @Override
    method delete (line 43) | @Override
    method findById (line 52) | @Override

FILE: chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/web/UserController.java
  class UserController (line 21) | @Controller
    method getUserList (line 33) | @RequestMapping(method = RequestMethod.GET)
    method createUserForm (line 45) | @RequestMapping(value = "/create", method = RequestMethod.GET)
    method postUser (line 57) | @RequestMapping(value = "/create", method = RequestMethod.POST)
    method getUser (line 78) | @RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
    method putUser (line 89) | @RequestMapping(value = "/update", method = RequestMethod.POST)
    method deleteUser (line 106) | @RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)

FILE: chapter-4-spring-boot-validating-form-input/src/test/java/spring/boot/core/ValidatingFormInputApplicationTests.java
  class ValidatingFormInputApplicationTests (line 8) | @RunWith(SpringRunner.class)
    method contextLoads (line 12) | @Test

FILE: chapter-4-spring-boot-validating-form-input/src/test/java/spring/boot/core/web/UserControllerTest.java
  class UserControllerTest (line 40) | @RunWith(SpringRunner.class)
    method getUserList (line 56) | @Test
    method createUser (line 64) | private User createUser() {
    method createUserForm (line 72) | @Test
    method postUser (line 83) | @Test
    method getUser (line 102) | @Test
    method putUser (line 127) | @Test
    method deleteUser (line 146) | @Test
    method convertObjectToJsonBytes (line 154) | public static byte[] convertObjectToJsonBytes(Object object) throws IO...

FILE: chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/WebApplication.java
  class WebApplication (line 11) | @SpringBootApplication
    method main (line 13) | public static void main(String[] args) {

FILE: chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/domain/Book.java
  class Book (line 10) | public class Book implements Serializable {
    method getId (line 32) | public Long getId() {
    method setId (line 36) | public void setId(Long id) {
    method getName (line 40) | public String getName() {
    method setName (line 44) | public void setName(String name) {
    method getWriter (line 48) | public String getWriter() {
    method setWriter (line 52) | public void setWriter(String writer) {
    method getIntroduction (line 56) | public String getIntroduction() {
    method setIntroduction (line 60) | public void setIntroduction(String introduction) {

FILE: chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/service/BookService.java
  type BookService (line 12) | public interface BookService {
    method findAll (line 16) | List<Book> findAll();
    method insertByBook (line 23) | Book insertByBook(Book book);
    method update (line 30) | Book update(Book book);
    method delete (line 37) | Book delete(Long id);
    method findById (line 44) | Book findById(Long id);

FILE: chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/service/impl/BookServiceImpl.java
  class BookServiceImpl (line 17) | @Service
    method findAll (line 24) | @Override
    method insertByBook (line 29) | @Override
    method update (line 36) | @Override
    method delete (line 42) | @Override
    method findById (line 47) | @Override

FILE: chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/web/BookController.java
  class BookController (line 15) | @Controller
    method getBookList (line 30) | @RequestMapping(method = RequestMethod.GET)
    method createBookForm (line 39) | @RequestMapping(value = "/create", method = RequestMethod.GET)
    method postBook (line 51) | @RequestMapping(value = "/create", method = RequestMethod.POST)
    method getUser (line 62) | @RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
    method putBook (line 73) | @RequestMapping(value = "/update", method = RequestMethod.POST)
    method deleteBook (line 83) | @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)

FILE: chapter-4-spring-boot-web-thymeleaf/src/test/java/demo/springboot/WebApplicationTests.java
  class WebApplicationTests (line 8) | @RunWith(SpringRunner.class)
    method contextLoads (line 12) | @Test

FILE: chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/WebApplication.java
  class WebApplication (line 11) | @SpringBootApplication
    method main (line 13) | public static void main(String[] args) {

FILE: chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/domain/Book.java
  class Book (line 13) | @Entity
    method getId (line 38) | public Long getId() {
    method setId (line 42) | public void setId(Long id) {
    method getName (line 46) | public String getName() {
    method setName (line 50) | public void setName(String name) {
    method getWriter (line 54) | public String getWriter() {
    method setWriter (line 58) | public void setWriter(String writer) {
    method getIntroduction (line 62) | public String getIntroduction() {
    method setIntroduction (line 66) | public void setIntroduction(String introduction) {

FILE: chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/domain/BookRepository.java
  type BookRepository (line 10) | public interface BookRepository extends JpaRepository<Book, Long> {

FILE: chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/service/BookService.java
  type BookService (line 12) | public interface BookService {
    method findAll (line 16) | List<Book> findAll();
    method insertByBook (line 23) | Book insertByBook(Book book);
    method update (line 30) | Book update(Book book);
    method delete (line 37) | Book delete(Long id);
    method findById (line 44) | Book findById(Long id);

FILE: chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/service/impl/BookServiceImpl.java
  class BookServiceImpl (line 16) | @Service
    method findAll (line 22) | @Override
    method insertByBook (line 27) | @Override
    method update (line 32) | @Override
    method delete (line 37) | @Override
    method findById (line 44) | @Override

FILE: chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/web/BookController.java
  class BookController (line 15) | @Controller
    method getBookList (line 30) | @RequestMapping(method = RequestMethod.GET)
    method createBookForm (line 39) | @RequestMapping(value = "/create", method = RequestMethod.GET)
    method postBook (line 51) | @RequestMapping(value = "/create", method = RequestMethod.POST)
    method getUser (line 62) | @RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
    method putBook (line 73) | @RequestMapping(value = "/update", method = RequestMethod.POST)
    method deleteBook (line 83) | @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)

FILE: chapter-5-spring-boot-data-jpa/src/test/java/demo/springboot/WebApplicationTests.java
  class WebApplicationTests (line 8) | @RunWith(SpringRunner.class)
    method contextLoads (line 12) | @Test

FILE: chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/PagingSortingApplication.java
  class PagingSortingApplication (line 11) | @SpringBootApplication
    method main (line 14) | public static void main(String[] args) {

FILE: chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/domain/User.java
  class User (line 13) | @Entity
    method getId (line 38) | public Long getId() {
    method setId (line 42) | public void setId(Long id) {
    method getName (line 46) | public String getName() {
    method setName (line 50) | public void setName(String name) {
    method getAge (line 54) | public Integer getAge() {
    method setAge (line 58) | public void setAge(Integer age) {
    method getBirthday (line 62) | public String getBirthday() {
    method setBirthday (line 66) | public void setBirthday(String birthday) {
    method toString (line 70) | @Override

FILE: chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/domain/UserRepository.java
  type UserRepository (line 10) | public interface UserRepository extends PagingAndSortingRepository<User,...

FILE: chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/service/UserService.java
  type UserService (line 13) | public interface UserService {
    method findByPage (line 21) | Page<User> findByPage(Pageable pageable);
    method insertByUser (line 29) | User insertByUser(User user);

FILE: chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/service/impl/UserServiceImpl.java
  class UserServiceImpl (line 18) | @Service
    method findByPage (line 26) | @Override
    method insertByUser (line 34) | @Override

FILE: chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/web/UserController.java
  class UserController (line 15) | @RestController
    method getUserPage (line 31) | @RequestMapping(method = RequestMethod.GET)
    method postUser (line 41) | @RequestMapping(value = "/create", method = RequestMethod.POST)

FILE: chapter-5-spring-boot-paging-sorting/src/test/java/spring/boot/core/PagingSortingApplicationTests.java
  class PagingSortingApplicationTests (line 8) | @RunWith(SpringRunner.class)
    method contextLoads (line 12) | @Test

FILE: spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/controller/CityRestController.java
  class CityRestController (line 16) | @RestController
    method createCity (line 28) | @RequestMapping(value = "/api/city", method = RequestMethod.POST)
    method findByDescriptionAndScore (line 40) | @RequestMapping(value = "/api/city/and/find", method = RequestMethod.GET)
    method findByDescriptionOrScore (line 53) | @RequestMapping(value = "/api/city/or/find", method = RequestMethod.GET)
    method findByDescription (line 65) | @RequestMapping(value = "/api/city/description/find", method = Request...
    method findByDescriptionNot (line 76) | @RequestMapping(value = "/api/city/description/not/find", method = Req...
    method findByDescriptionLike (line 87) | @RequestMapping(value = "/api/city/like/find", method = RequestMethod....

FILE: spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/domain/City.java
  class City (line 12) | @Document(indexName = "province", type = "city")
    method getId (line 37) | public Long getId() {
    method setId (line 41) | public void setId(Long id) {
    method getName (line 45) | public String getName() {
    method setName (line 49) | public void setName(String name) {
    method getDescription (line 53) | public String getDescription() {
    method setDescription (line 57) | public void setDescription(String description) {
    method getScore (line 61) | public Integer getScore() {
    method setScore (line 65) | public void setScore(Integer score) {

FILE: spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/repository/CityRepository.java
  type CityRepository (line 16) | public interface CityRepository extends ElasticsearchRepository<City, Lo...
    method findByDescriptionAndScore (line 24) | List<City> findByDescriptionAndScore(String description, Integer score);
    method findByDescriptionOrScore (line 33) | List<City> findByDescriptionOrScore(String description, Integer score);
    method findByDescription (line 46) | Page<City> findByDescription(String description, Pageable page);
    method findByDescriptionNot (line 55) | Page<City> findByDescriptionNot(String description, Pageable page);
    method findByDescriptionLike (line 64) | Page<City> findByDescriptionLike(String description, Pageable page);

FILE: spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/service/CityService.java
  type CityService (line 12) | public interface CityService {
    method saveCity (line 20) | Long saveCity(City city);
    method findByDescriptionAndScore (line 29) | List<City> findByDescriptionAndScore(String description, Integer score);
    method findByDescriptionOrScore (line 38) | List<City> findByDescriptionOrScore(String description, Integer score);
    method findByDescription (line 46) | List<City> findByDescription(String description);
    method findByDescriptionNot (line 54) | List<City> findByDescriptionNot(String description);
    method findByDescriptionLike (line 62) | List<City> findByDescriptionLike(String description);

FILE: spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/service/impl/CityESServiceImpl.java
  class CityESServiceImpl (line 21) | @Service
    method saveCity (line 35) | public Long saveCity(City city) {
    method findByDescriptionAndScore (line 40) | public List<City> findByDescriptionAndScore(String description, Intege...
    method findByDescriptionOrScore (line 44) | public List<City> findByDescriptionOrScore(String description, Integer...
    method findByDescription (line 48) | public List<City> findByDescription(String description) {
    method findByDescriptionNot (line 52) | public List<City> findByDescriptionNot(String description) {
    method findByDescriptionLike (line 56) | public List<City> findByDescriptionLike(String description) {

FILE: spring-data-elasticsearch-query/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: spring-data-elasticsearch-query/src/main/java/org/spring/springboot/controller/CityRestController.java
  class CityRestController (line 16) | @RestController
    method createCity (line 28) | @RequestMapping(value = "/api/city", method = RequestMethod.POST)
    method searchCity (line 41) | @RequestMapping(value = "/api/city/search", method = RequestMethod.GET)

FILE: spring-data-elasticsearch-query/src/main/java/org/spring/springboot/domain/City.java
  class City (line 12) | @Document(indexName = "province", type = "city")
    method getId (line 37) | public Long getId() {
    method setId (line 41) | public void setId(Long id) {
    method getName (line 45) | public String getName() {
    method setName (line 49) | public void setName(String name) {
    method getDescription (line 53) | public String getDescription() {
    method setDescription (line 57) | public void setDescription(String description) {
    method getScore (line 61) | public Integer getScore() {
    method setScore (line 65) | public void setScore(Integer score) {

FILE: spring-data-elasticsearch-query/src/main/java/org/spring/springboot/repository/CityRepository.java
  type CityRepository (line 16) | public interface CityRepository extends ElasticsearchRepository<City, Lo...

FILE: spring-data-elasticsearch-query/src/main/java/org/spring/springboot/service/CityService.java
  type CityService (line 12) | public interface CityService {
    method saveCity (line 20) | Long saveCity(City city);
    method searchCity (line 30) | List<City> searchCity(Integer pageNumber, Integer pageSize, String sea...

FILE: spring-data-elasticsearch-query/src/main/java/org/spring/springboot/service/impl/CityESServiceImpl.java
  class CityESServiceImpl (line 26) | @Service
    method saveCity (line 42) | public Long saveCity(City city) {
    method searchCity (line 47) | @Override
    method getCitySearchQuery (line 84) | private SearchQuery getCitySearchQuery(Integer pageNumber, Integer pag...

FILE: springboot-configuration/src/main/java/org/spring/springboot/Application.java
  class Application (line 11) | @SpringBootApplication
    method main (line 14) | public static void main(String[] args) {

FILE: springboot-configuration/src/main/java/org/spring/springboot/config/MessageConfiguration.java
  class MessageConfiguration (line 9) | @Configuration
    method message (line 12) | @Bean

FILE: springboot-configuration/src/test/java/org/spring/springboot/config/MessageConfigurationTest.java
  class MessageConfigurationTest (line 12) | public class MessageConfigurationTest {
    method testGetMessageBean (line 14) | @Test
    method testScanPackages (line 20) | @Test

FILE: springboot-dubbo-client/src/main/java/org/spring/springboot/ClientApplication.java
  class ClientApplication (line 14) | @SpringBootApplication
    method main (line 17) | public static void main(String[] args) {

FILE: springboot-dubbo-client/src/main/java/org/spring/springboot/domain/City.java
  class City (line 10) | public class City implements Serializable {
    method getId (line 34) | public Long getId() {
    method setId (line 38) | public void setId(Long id) {
    method getProvinceId (line 42) | public Long getProvinceId() {
    method setProvinceId (line 46) | public void setProvinceId(Long provinceId) {
    method getCityName (line 50) | public String getCityName() {
    method setCityName (line 54) | public void setCityName(String cityName) {
    method getDescription (line 58) | public String getDescription() {
    method setDescription (line 62) | public void setDescription(String description) {
    method toString (line 66) | @Override

FILE: springboot-dubbo-client/src/main/java/org/spring/springboot/dubbo/CityDubboConsumerService.java
  class CityDubboConsumerService (line 12) | @Component
    method printCity (line 18) | public void printCity() {

FILE: springboot-dubbo-client/src/main/java/org/spring/springboot/dubbo/CityDubboService.java
  type CityDubboService (line 10) | public interface CityDubboService {
    method findCityByName (line 16) | City findCityByName(String cityName);

FILE: springboot-dubbo-server/src/main/java/org/spring/springboot/ServerApplication.java
  class ServerApplication (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: springboot-dubbo-server/src/main/java/org/spring/springboot/domain/City.java
  class City (line 10) | public class City implements Serializable {
    method City (line 34) | public City() {
    method City (line 37) | public City(Long id, Long provinceId, String cityName, String descript...
    method getId (line 44) | public Long getId() {
    method setId (line 48) | public void setId(Long id) {
    method getProvinceId (line 52) | public Long getProvinceId() {
    method setProvinceId (line 56) | public void setProvinceId(Long provinceId) {
    method getCityName (line 60) | public String getCityName() {
    method setCityName (line 64) | public void setCityName(String cityName) {
    method getDescription (line 68) | public String getDescription() {
    method setDescription (line 72) | public void setDescription(String description) {

FILE: springboot-dubbo-server/src/main/java/org/spring/springboot/dubbo/CityDubboService.java
  type CityDubboService (line 10) | public interface CityDubboService {
    method findCityByName (line 16) | City findCityByName(String cityName);

FILE: springboot-dubbo-server/src/main/java/org/spring/springboot/dubbo/impl/CityDubboServiceImpl.java
  class CityDubboServiceImpl (line 14) | @Service(version = "1.0.0")
    method findCityByName (line 17) | public City findCityByName(String cityName) {

FILE: springboot-elasticsearch/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: springboot-elasticsearch/src/main/java/org/spring/springboot/controller/CityRestController.java
  class CityRestController (line 15) | @RestController
    method createCity (line 21) | @RequestMapping(value = "/api/city", method = RequestMethod.POST)
    method searchCity (line 26) | @RequestMapping(value = "/api/city/search", method = RequestMethod.GET)

FILE: springboot-elasticsearch/src/main/java/org/spring/springboot/domain/City.java
  class City (line 12) | @Document(indexName = "cityindex", type = "city")
    method getId (line 37) | public Long getId() {
    method setId (line 41) | public void setId(Long id) {
    method getProvinceid (line 45) | public Long getProvinceid() {
    method setProvinceid (line 49) | public void setProvinceid(Long provinceid) {
    method getCityname (line 53) | public String getCityname() {
    method setCityname (line 57) | public void setCityname(String cityname) {
    method getDescription (line 61) | public String getDescription() {
    method setDescription (line 65) | public void setDescription(String description) {

FILE: springboot-elasticsearch/src/main/java/org/spring/springboot/repository/CityRepository.java
  type CityRepository (line 10) | @Repository

FILE: springboot-elasticsearch/src/main/java/org/spring/springboot/service/CityService.java
  type CityService (line 7) | public interface CityService {
    method saveCity (line 15) | Long saveCity(City city);
    method searchCity (line 25) | List<City> searchCity(Integer pageNumber, Integer pageSize, String sea...

FILE: springboot-elasticsearch/src/main/java/org/spring/springboot/service/impl/CityESServiceImpl.java
  class CityESServiceImpl (line 27) | @Service
    method saveCity (line 35) | @Override
    method searchCity (line 42) | @Override

FILE: springboot-freemarker/src/main/java/org/spring/springboot/Application.java
  class Application (line 16) | @SpringBootApplication
    method main (line 21) | public static void main(String[] args) {

FILE: springboot-freemarker/src/main/java/org/spring/springboot/controller/CityController.java
  class CityController (line 17) | @Controller
    method findOneCity (line 23) | @RequestMapping(value = "/api/city/{id}", method = RequestMethod.GET)
    method findAllCity (line 29) | @RequestMapping(value = "/api/city", method = RequestMethod.GET)

FILE: springboot-freemarker/src/main/java/org/spring/springboot/dao/CityDao.java
  type CityDao (line 13) | public interface CityDao {
    method findAllCity (line 20) | List<City> findAllCity();
    method findById (line 28) | City findById(@Param("id") Long id);
    method saveCity (line 30) | Long saveCity(City city);
    method updateCity (line 32) | Long updateCity(City city);
    method deleteCity (line 34) | Long deleteCity(Long id);

FILE: springboot-freemarker/src/main/java/org/spring/springboot/domain/City.java
  class City (line 8) | public class City {
    method getId (line 30) | public Long getId() {
    method setId (line 34) | public void setId(Long id) {
    method getProvinceId (line 38) | public Long getProvinceId() {
    method setProvinceId (line 42) | public void setProvinceId(Long provinceId) {
    method getCityName (line 46) | public String getCityName() {
    method setCityName (line 50) | public void setCityName(String cityName) {
    method getDescription (line 54) | public String getDescription() {
    method setDescription (line 58) | public void setDescription(String description) {

FILE: springboot-freemarker/src/main/java/org/spring/springboot/service/CityService.java
  type CityService (line 12) | public interface CityService {
    method findAllCity (line 19) | List<City> findAllCity();
    method findCityById (line 27) | City findCityById(Long id);
    method saveCity (line 35) | Long saveCity(City city);
    method updateCity (line 43) | Long updateCity(City city);
    method deleteCity (line 51) | Long deleteCity(Long id);

FILE: springboot-freemarker/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java
  class CityServiceImpl (line 16) | @Service
    method findAllCity (line 22) | public List<City> findAllCity(){
    method findCityById (line 26) | public City findCityById(Long id) {
    method saveCity (line 30) | @Override
    method updateCity (line 35) | @Override
    method deleteCity (line 40) | @Override

FILE: springboot-hbase/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: springboot-hbase/src/main/java/org/spring/springboot/controller/CityRestController.java
  class CityRestController (line 13) | @RestController
    method save (line 19) | @RequestMapping(value = "/api/city/save", method = RequestMethod.GET)
    method getCity (line 27) | @RequestMapping(value = "/api/city/get", method = RequestMethod.GET)

FILE: springboot-hbase/src/main/java/org/spring/springboot/dao/CityRowMapper.java
  class CityRowMapper (line 8) | public class CityRowMapper implements RowMapper<City> {
    method mapRow (line 14) | @Override

FILE: springboot-hbase/src/main/java/org/spring/springboot/domain/City.java
  class City (line 8) | public class City {
    method getId (line 25) | public Long getId() {
    method setId (line 29) | public void setId(Long id) {
    method getAge (line 33) | public Integer getAge() {
    method setAge (line 37) | public void setAge(Integer age) {
    method getCityName (line 41) | public String getCityName() {
    method setCityName (line 45) | public void setCityName(String cityName) {

FILE: springboot-hbase/src/main/java/org/spring/springboot/service/CityService.java
  type CityService (line 12) | public interface CityService {
    method query (line 14) | List<City> query(String startRow, String stopRow);
    method query (line 16) | public City query(String row);
    method saveOrUpdate (line 18) | void saveOrUpdate();

FILE: springboot-hbase/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java
  class CityServiceImpl (line 22) | @Service
    method query (line 27) | public List<City> query(String startRow, String stopRow) {
    method query (line 34) | public City query(String row) {
    method saveOrUpdate (line 39) | public void saveOrUpdate() {

FILE: springboot-helloworld/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: springboot-helloworld/src/main/java/org/spring/springboot/web/HelloWorldController.java
  class HelloWorldController (line 11) | @RestController
    method sayHello (line 14) | @RequestMapping("/")

FILE: springboot-helloworld/src/test/java/org/spring/springboot/web/HelloWorldControllerTest.java
  class HelloWorldControllerTest (line 12) | public class HelloWorldControllerTest {
    method testSayHello (line 14) | @Test

FILE: springboot-mybatis-annotation/src/main/java/org/spring/springboot/Application.java
  class Application (line 6) | @SpringBootApplication
    method main (line 9) | public static void main(String[] args) {

FILE: springboot-mybatis-annotation/src/main/java/org/spring/springboot/controller/CityRestController.java
  class CityRestController (line 14) | @RestController
    method findOneCity (line 20) | @RequestMapping(value = "/api/city", method = RequestMethod.GET)

FILE: springboot-mybatis-annotation/src/main/java/org/spring/springboot/dao/CityDao.java
  type CityDao (line 11) | @Mapper // 标志为 Mybatis 的 Mapper
    method findByName (line 19) | @Select("SELECT * FROM city")

FILE: springboot-mybatis-annotation/src/main/java/org/spring/springboot/domain/City.java
  class City (line 8) | public class City {
    method getId (line 30) | public Long getId() {
    method setId (line 34) | public void setId(Long id) {
    method getProvinceId (line 38) | public Long getProvinceId() {
    method setProvinceId (line 42) | public void setProvinceId(Long provinceId) {
    method getCityName (line 46) | public String getCityName() {
    method setCityName (line 50) | public void setCityName(String cityName) {
    method getDescription (line 54) | public String getDescription() {
    method setDescription (line 58) | public void setDescription(String description) {

FILE: springboot-mybatis-annotation/src/main/java/org/spring/springboot/service/CityService.java
  type CityService (line 10) | public interface CityService {
    method findCityByName (line 16) | City findCityByName(String cityName);

FILE: springboot-mybatis-annotation/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java
  class CityServiceImpl (line 14) | @Service
    method findCityByName (line 20) | public City findCityByName(String cityName) {

FILE: springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/config/ds/ClusterDataSourceConfig.java
  class ClusterDataSourceConfig (line 17) | @Configuration
    method clusterDataSource (line 38) | @Bean(name = "clusterDataSource")
    method clusterTransactionManager (line 48) | @Bean(name = "clusterTransactionManager")
    method clusterSqlSessionFactory (line 53) | @Bean(name = "clusterSqlSessionFactory")

FILE: springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/config/ds/MasterDataSourceConfig.java
  class MasterDataSourceConfig (line 18) | @Configuration
    method masterDataSource (line 39) | @Bean(name = "masterDataSource")
    method masterTransactionManager (line 50) | @Bean(name = "masterTransactionManager")
    method masterSqlSessionFactory (line 56) | @Bean(name = "masterSqlSessionFactory")

FILE: springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/controller/UserRestController.java
  class UserRestController (line 17) | @RestController
    method findByName (line 29) | @RequestMapping(value = "/api/user", method = RequestMethod.GET)

FILE: springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/dao/cluster/CityDao.java
  type CityDao (line 12) | @Mapper
    method findByName (line 20) | City findByName(@Param("cityName") String cityName);

FILE: springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/dao/master/UserDao.java
  type UserDao (line 12) | @Mapper
    method findByName (line 21) | User findByName(@Param("userName") String userName);

FILE: springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/domain/City.java
  class City (line 10) | public class City {
    method getId (line 32) | public Long getId() {
    method setId (line 36) | public void setId(Long id) {
    method getProvinceId (line 40) | public Long getProvinceId() {
    method setProvinceId (line 44) | public void setProvinceId(Long provinceId) {
    method getCityName (line 48) | public String getCityName() {
    method setCityName (line 52) | public void setCityName(String cityName) {
    method getDescription (line 56) | public String getDescription() {
    method setDescription (line 60) | public void setDescription(String description) {

FILE: springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/domain/User.java
  class User (line 8) | public class User {
    method getCity (line 27) | public City getCity() {
    method setCity (line 31) | public void setCity(City city) {
    method getId (line 35) | public Long getId() {
    method setId (line 39) | public void setId(Long id) {
    method getUserName (line 43) | public String getUserName() {
    method setUserName (line 47) | public void setUserName(String userName) {
    method getDescription (line 51) | public String getDescription() {
    method setDescription (line 55) | public void setDescription(String description) {

FILE: springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/service/UserService.java
  type UserService (line 11) | public interface UserService {
    method findByName (line 19) | User findByName(String userName);

FILE: springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/service/impl/UserServiceImpl.java
  class UserServiceImpl (line 16) | @Service
    method findByName (line 25) | @Override

FILE: springboot-mybatis-redis-annotation/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: springboot-mybatis-redis-annotation/src/main/java/org/spring/springboot/domain/City.java
  class City (line 10) | public class City implements Serializable {
    method City (line 34) | public City(Long id, Long provinceId, String cityName, String descript...
    method getId (line 41) | public Long getId() {
    method setId (line 45) | public void setId(Long id) {
    method getProvinceId (line 49) | public Long getProvinceId() {
    method setProvinceId (line 53) | public void setProvinceId(Long provinceId) {
    method getCityName (line 57) | public String getCityName() {
    method setCityName (line 61) | public void setCityName(String cityName) {
    method getDescription (line 65) | public String getDescription() {
    method setDescription (line 69) | public void setDescription(String description) {
    method toString (line 73) | @Override

FILE: springboot-mybatis-redis-annotation/src/main/java/org/spring/springboot/service/CityService.java
  type CityService (line 12) | public interface CityService {
    method getCityByName (line 18) | City getCityByName(String cityName);
    method saveCity (line 24) | void saveCity(City city);
    method updateCityDescription (line 30) | void updateCityDescription(String cityName, String description);

FILE: springboot-mybatis-redis-annotation/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java
  class CityServiceImpl (line 19) | @Service
    method saveCity (line 26) | public void saveCity(City city){
    method getCityByName (line 31) | @Cacheable(value = "baseCityInfo")
    method updateCityDescription (line 37) | @CachePut(value = "baseCityInfo")

FILE: springboot-mybatis-redis-annotation/src/test/org/spring/springboot/ApplicationTests.java
  class ApplicationTests (line 17) | @RunWith(SpringRunner.class)
    method testRedis (line 27) | @Test
    method testRedisCache (line 40) | @Test
    method getShanghai (line 63) | private City getShanghai(){
    method getBeijing (line 67) | private City getBeijing(){

FILE: springboot-mybatis-redis/src/main/java/org/spring/springboot/Application.java
  class Application (line 16) | @SpringBootApplication
    method main (line 21) | public static void main(String[] args) {

FILE: springboot-mybatis-redis/src/main/java/org/spring/springboot/controller/CityRestController.java
  class CityRestController (line 14) | @RestController
    method findOneCity (line 21) | @RequestMapping(value = "/api/city/{id}", method = RequestMethod.GET)
    method createCity (line 26) | @RequestMapping(value = "/api/city", method = RequestMethod.POST)
    method modifyCity (line 31) | @RequestMapping(value = "/api/city", method = RequestMethod.PUT)
    method modifyCity (line 36) | @RequestMapping(value = "/api/city/{id}", method = RequestMethod.DELETE)

FILE: springboot-mybatis-redis/src/main/java/org/spring/springboot/dao/CityDao.java
  type CityDao (line 13) | public interface CityDao {
    method findAllCity (line 20) | List<City> findAllCity();
    method findById (line 28) | City findById(@Param("id") Long id);
    method saveCity (line 30) | Long saveCity(City city);
    method updateCity (line 32) | Long updateCity(City city);
    method deleteCity (line 34) | Long deleteCity(Long id);

FILE: springboot-mybatis-redis/src/main/java/org/spring/springboot/domain/City.java
  class City (line 10) | public class City implements Serializable {
    method getId (line 34) | public Long getId() {
    method setId (line 38) | public void setId(Long id) {
    method getProvinceId (line 42) | public Long getProvinceId() {
    method setProvinceId (line 46) | public void setProvinceId(Long provinceId) {
    method getCityName (line 50) | public String getCityName() {
    method setCityName (line 54) | public void setCityName(String cityName) {
    method getDescription (line 58) | public String getDescription() {
    method setDescription (line 62) | public void setDescription(String description) {
    method toString (line 66) | @Override

FILE: springboot-mybatis-redis/src/main/java/org/spring/springboot/service/CityService.java
  type CityService (line 12) | public interface CityService {
    method findCityById (line 19) | City findCityById(Long id);
    method saveCity (line 27) | Long saveCity(City city);
    method updateCity (line 35) | Long updateCity(City city);
    method deleteCity (line 43) | Long deleteCity(Long id);

FILE: springboot-mybatis-redis/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java
  class CityServiceImpl (line 22) | @Service
    method findCityById (line 38) | public City findCityById(Long id) {
    method saveCity (line 62) | @Override
    method updateCity (line 72) | @Override
    method deleteCity (line 88) | @Override

FILE: springboot-mybatis/src/main/java/org/spring/springboot/Application.java
  class Application (line 16) | @SpringBootApplication
    method main (line 21) | public static void main(String[] args) {

FILE: springboot-mybatis/src/main/java/org/spring/springboot/controller/CityRestController.java
  class CityRestController (line 15) | @RestController
    method findOneCity (line 21) | @RequestMapping(value = "/api/city", method = RequestMethod.GET)

FILE: springboot-mybatis/src/main/java/org/spring/springboot/dao/CityDao.java
  type CityDao (line 11) | public interface CityDao {
    method findByName (line 18) | City findByName(@Param("cityName") String cityName);

FILE: springboot-mybatis/src/main/java/org/spring/springboot/domain/City.java
  class City (line 8) | public class City {
    method getId (line 30) | public Long getId() {
    method setId (line 34) | public void setId(Long id) {
    method getProvinceId (line 38) | public Long getProvinceId() {
    method setProvinceId (line 42) | public void setProvinceId(Long provinceId) {
    method getCityName (line 46) | public String getCityName() {
    method setCityName (line 50) | public void setCityName(String cityName) {
    method getDescription (line 54) | public String getDescription() {
    method setDescription (line 58) | public void setDescription(String description) {

FILE: springboot-mybatis/src/main/java/org/spring/springboot/service/CityService.java
  type CityService (line 10) | public interface CityService {
    method findCityByName (line 16) | City findCityByName(String cityName);

FILE: springboot-mybatis/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java
  class CityServiceImpl (line 14) | @Service
    method findCityByName (line 20) | public City findCityByName(String cityName) {

FILE: springboot-properties/src/main/java/org/spring/springboot/Application.java
  class Application (line 15) | @SpringBootApplication
    method main (line 21) | public static void main(String[] args) {
    method run (line 27) | @Override

FILE: springboot-properties/src/main/java/org/spring/springboot/property/HomeProperties.java
  class HomeProperties (line 12) | @Component
    method getProvince (line 31) | public String getProvince() {
    method setProvince (line 35) | public void setProvince(String province) {
    method getCity (line 39) | public String getCity() {
    method setCity (line 43) | public void setCity(String city) {
    method getDesc (line 47) | public String getDesc() {
    method setDesc (line 51) | public void setDesc(String desc) {
    method toString (line 55) | @Override

FILE: springboot-properties/src/main/java/org/spring/springboot/property/UserProperties.java
  class UserProperties (line 9) | @Component
    method getId (line 32) | public Long getId() {
    method setId (line 36) | public void setId(Long id) {
    method getAge (line 40) | public int getAge() {
    method setAge (line 44) | public void setAge(int age) {
    method getDesc (line 48) | public String getDesc() {
    method setDesc (line 52) | public void setDesc(String desc) {
    method getUuid (line 56) | public String getUuid() {
    method setUuid (line 60) | public void setUuid(String uuid) {
    method toString (line 65) | @Override

FILE: springboot-properties/src/main/java/org/spring/springboot/web/HelloWorldController.java
  class HelloWorldController (line 11) | @RestController
    method sayHello (line 14) | @RequestMapping("/")

FILE: springboot-properties/src/test/java/org/spring/springboot/property/HomeProperties1.java
  class HomeProperties1 (line 11) | @Component
    method getProvince (line 32) | public String getProvince() {
    method setProvince (line 36) | public void setProvince(String province) {
    method getCity (line 40) | public String getCity() {
    method setCity (line 44) | public void setCity(String city) {
    method getDesc (line 48) | public String getDesc() {
    method setDesc (line 52) | public void setDesc(String desc) {
    method toString (line 56) | @Override

FILE: springboot-properties/src/test/java/org/spring/springboot/property/PropertiesTest.java
  class PropertiesTest (line 17) | @RunWith(SpringRunner.class)
    method getHomeProperties (line 29) | @Test
    method randomTestUser (line 34) | @Test

FILE: springboot-properties/src/test/java/org/spring/springboot/web/HelloWorldControllerTest.java
  class HelloWorldControllerTest (line 12) | public class HelloWorldControllerTest {
    method testSayHello (line 14) | @Test

FILE: springboot-restful/src/main/java/org/spring/springboot/Application.java
  class Application (line 16) | @SpringBootApplication
    method main (line 21) | public static void main(String[] args) {

FILE: springboot-restful/src/main/java/org/spring/springboot/controller/CityRestController.java
  class CityRestController (line 16) | @RestController
    method findOneCity (line 22) | @RequestMapping(value = "/api/city/{id}", method = RequestMethod.GET)
    method findAllCity (line 27) | @RequestMapping(value = "/api/city", method = RequestMethod.GET)
    method createCity (line 32) | @RequestMapping(value = "/api/city", method = RequestMethod.POST)
    method modifyCity (line 37) | @RequestMapping(value = "/api/city", method = RequestMethod.PUT)
    method modifyCity (line 42) | @RequestMapping(value = "/api/city/{id}", method = RequestMethod.DELETE)

FILE: springboot-restful/src/main/java/org/spring/springboot/dao/CityDao.java
  type CityDao (line 13) | public interface CityDao {
    method findAllCity (line 20) | List<City> findAllCity();
    method findById (line 28) | City findById(@Param("id") Long id);
    method saveCity (line 30) | Long saveCity(City city);
    method updateCity (line 32) | Long updateCity(City city);
    method deleteCity (line 34) | Long deleteCity(Long id);

FILE: springboot-restful/src/main/java/org/spring/springboot/domain/City.java
  class City (line 8) | public class City {
    method getId (line 30) | public Long getId() {
    method setId (line 34) | public void setId(Long id) {
    method getProvinceId (line 38) | public Long getProvinceId() {
    method setProvinceId (line 42) | public void setProvinceId(Long provinceId) {
    method getCityName (line 46) | public String getCityName() {
    method setCityName (line 50) | public void setCityName(String cityName) {
    method getDescription (line 54) | public String getDescription() {
    method setDescription (line 58) | public void setDescription(String description) {

FILE: springboot-restful/src/main/java/org/spring/springboot/service/CityService.java
  type CityService (line 12) | public interface CityService {
    method findAllCity (line 19) | List<City> findAllCity();
    method findCityById (line 27) | City findCityById(Long id);
    method saveCity (line 35) | Long saveCity(City city);
    method updateCity (line 43) | Long updateCity(City city);
    method deleteCity (line 51) | Long deleteCity(Long id);

FILE: springboot-restful/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java
  class CityServiceImpl (line 16) | @Service
    method findAllCity (line 22) | public List<City> findAllCity(){
    method findCityById (line 26) | public City findCityById(Long id) {
    method saveCity (line 30) | @Override
    method updateCity (line 35) | @Override
    method deleteCity (line 40) | @Override

FILE: springboot-validation-over-json/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: springboot-validation-over-json/src/main/java/org/spring/springboot/constant/CityErrorInfoEnum.java
  type CityErrorInfoEnum (line 10) | public enum CityErrorInfoEnum implements ErrorInfoInterface {
    method CityErrorInfoEnum (line 18) | CityErrorInfoEnum(String code, String message) {
    method getCode (line 23) | public String getCode(){
    method getMessage (line 27) | public String getMessage(){

FILE: springboot-validation-over-json/src/main/java/org/spring/springboot/result/ErrorInfoInterface.java
  type ErrorInfoInterface (line 8) | public interface ErrorInfoInterface {
    method getCode (line 9) | String getCode();
    method getMessage (line 10) | String getMessage();

FILE: springboot-validation-over-json/src/main/java/org/spring/springboot/result/GlobalErrorInfoEnum.java
  type GlobalErrorInfoEnum (line 8) | public enum GlobalErrorInfoEnum implements ErrorInfoInterface{
    method GlobalErrorInfoEnum (line 16) | GlobalErrorInfoEnum(String code, String message) {
    method getCode (line 21) | public String getCode(){
    method getMessage (line 25) | public String getMessage(){

FILE: springboot-validation-over-json/src/main/java/org/spring/springboot/result/GlobalErrorInfoException.java
  class GlobalErrorInfoException (line 8) | public class GlobalErrorInfoException extends Exception {
    method GlobalErrorInfoException (line 12) | public GlobalErrorInfoException (ErrorInfoInterface errorInfo) {
    method getErrorInfo (line 16) | public ErrorInfoInterface getErrorInfo() {
    method setErrorInfo (line 20) | public void setErrorInfo(ErrorInfoInterface errorInfo) {

FILE: springboot-validation-over-json/src/main/java/org/spring/springboot/result/GlobalErrorInfoHandler.java
  class GlobalErrorInfoHandler (line 13) | @RestControllerAdvice
    method errorHandlerOverJson (line 16) | @ExceptionHandler(value = GlobalErrorInfoException.class)

FILE: springboot-validation-over-json/src/main/java/org/spring/springboot/result/ResultBody.java
  class ResultBody (line 8) | public class ResultBody {
    method ResultBody (line 24) | public ResultBody(ErrorInfoInterface errorInfo) {
    method ResultBody (line 29) | public ResultBody(Object result) {
    method getCode (line 35) | public String getCode() {
    method setCode (line 39) | public void setCode(String code) {
    method getMessage (line 43) | public String getMessage() {
    method setMessage (line 47) | public void setMessage(String message) {
    method getResult (line 51) | public Object getResult() {
    method setResult (line 55) | public void setResult(Object result) {

FILE: springboot-validation-over-json/src/main/java/org/spring/springboot/web/City.java
  class City (line 10) | public class City implements Serializable {
    method City (line 34) | public City() {
    method City (line 37) | public City(Long id, Long provinceId, String cityName, String descript...
    method getId (line 44) | public Long getId() {
    method setId (line 48) | public void setId(Long id) {
    method getProvinceId (line 52) | public Long getProvinceId() {
    method setProvinceId (line 56) | public void setProvinceId(Long provinceId) {
    method getCityName (line 60) | public String getCityName() {
    method setCityName (line 64) | public void setCityName(String cityName) {
    method getDescription (line 68) | public String getDescription() {
    method setDescription (line 72) | public void setDescription(String description) {

FILE: springboot-validation-over-json/src/main/java/org/spring/springboot/web/ErrorJsonController.java
  class ErrorJsonController (line 17) | @RestController
    method findOneCity (line 28) | @RequestMapping(value = "/api/city", method = RequestMethod.GET)

FILE: springboot-validation-over-json/src/test/java/org/spring/springboot/web/ErrorJsonControllerTest.java
  class ErrorJsonControllerTest (line 10) | public class ErrorJsonControllerTest {
    method testSayHello (line 12) | @Test

FILE: springboot-webflux-1-quickstart/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: springboot-webflux-1-quickstart/src/main/java/org/spring/springboot/handler/CityHandler.java
  class CityHandler (line 10) | @Component
    method helloCity (line 13) | public Mono<ServerResponse> helloCity(ServerRequest request) {

FILE: springboot-webflux-1-quickstart/src/main/java/org/spring/springboot/router/CityRouter.java
  class CityRouter (line 12) | @Configuration
    method routeCity (line 16) | @Bean

FILE: springboot-webflux-10-book-manage-sys/src/main/java/demo/springboot/WebApplication.java
  class WebApplication (line 11) | @SpringBootApplication
    method main (line 13) | public static void main(String[] args) {

FILE: springboot-webflux-10-book-manage-sys/src/main/java/demo/springboot/dao/CityRepository.java
  type CityRepository (line 7) | @Repository

FILE: springboot-webflux-10-book-manage-sys/src/main/java/demo/springboot/domain/City.java
  class City (line 7) | public class City {
    method getId (line 29) | public Long getId() {
    method setId (line 33) | public void setId(Long id) {
    method getProvinceId (line 37) | public Long getProvinceId() {
    method setProvinceId (line 41) | public void setProvinceId(Long provinceId) {
    method getCityName (line 45) | public String getCityName() {
    method setCityName (line 49) | public void setCityName(String cityName) {
    method getDescription (line 53) | public String getDescription() {
    method setDescription (line 57) | public void setDescription(String description) {

FILE: springboot-webflux-10-book-manage-sys/src/main/java/demo/springboot/service/CityService.java
  type CityService (line 7) | public interface CityService {
    method findAll (line 9) | Flux<City> findAll();
    method insertByCity (line 11) | Mono<City> insertByCity(City city);
    method update (line 13) | Mono<City> update(City city);
    method delete (line 15) | Mono<Void> delete(Long id);
    method findById (line 17) | Mono<City> findById(Long id);

FILE: springboot-webflux-10-book-manage-sys/src/main/java/demo/springboot/service/impl/CityServiceImpl.java
  class CityServiceImpl (line 11) | @Component
    method CityServiceImpl (line 16) | @Autowired
    method findAll (line 21) | @Override
    method insertByCity (line 26) | @Override
    method update (line 31) | @Override
    method delete (line 36) | @Override
    method findById (line 41) | @Override

FILE: springboot-webflux-10-book-manage-sys/src/main/java/demo/springboot/web/CityController.java
  class CityController (line 21) | @Controller
    method getCityList (line 32) | @RequestMapping(method = RequestMethod.GET)
    method createCityForm (line 38) | @RequestMapping(value = "/create", method = RequestMethod.GET)
    method postCity (line 45) | @RequestMapping(value = "/create", method = RequestMethod.POST)
    method getCity (line 51) | @RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
    method putBook (line 59) | @RequestMapping(value = "/update", method = RequestMethod.POST)
    method deleteCity (line 65) | @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)

FILE: springboot-webflux-2-restful/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: springboot-webflux-2-restful/src/main/java/org/spring/springboot/dao/CityRepository.java
  class CityRepository (line 11) | @Repository
    method save (line 18) | public Long save(City city) {
    method findAll (line 25) | public Collection<City> findAll() {
    method findCityById (line 30) | public City findCityById(Long id) {
    method updateCity (line 34) | public Long updateCity(City city) {
    method deleteCity (line 39) | public Long deleteCity(Long id) {

FILE: springboot-webflux-2-restful/src/main/java/org/spring/springboot/domain/City.java
  class City (line 7) | public class City {
    method getId (line 29) | public Long getId() {
    method setId (line 33) | public void setId(Long id) {
    method getProvinceId (line 37) | public Long getProvinceId() {
    method setProvinceId (line 41) | public void setProvinceId(Long provinceId) {
    method getCityName (line 45) | public String getCityName() {
    method setCityName (line 49) | public void setCityName(String cityName) {
    method getDescription (line 53) | public String getDescription() {
    method setDescription (line 57) | public void setDescription(String description) {

FILE: springboot-webflux-2-restful/src/main/java/org/spring/springboot/handler/CityHandler.java
  class CityHandler (line 10) | @Component
    method CityHandler (line 15) | @Autowired
    method save (line 20) | public Mono<Long> save(City city) {
    method findCityById (line 24) | public Mono<City> findCityById(Long id) {
    method findAllCity (line 28) | public Flux<City> findAllCity() {
    method modifyCity (line 32) | public Mono<Long> modifyCity(City city) {
    method deleteCity (line 36) | public Mono<Long> deleteCity(Long id) {

FILE: springboot-webflux-2-restful/src/main/java/org/spring/springboot/webflux/controller/CityWebFluxController.java
  class CityWebFluxController (line 10) | @RestController
    method findCityById (line 17) | @GetMapping(value = "/{id}")
    method findAllCity (line 22) | @GetMapping()
    method saveCity (line 27) | @PostMapping()
    method modifyCity (line 32) | @PutMapping()
    method deleteCity (line 37) | @DeleteMapping(value = "/{id}")

FILE: springboot-webflux-3-mongodb/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: springboot-webflux-3-mongodb/src/main/java/org/spring/springboot/dao/CityRepository.java
  type CityRepository (line 7) | @Repository

FILE: springboot-webflux-3-mongodb/src/main/java/org/spring/springboot/domain/City.java
  class City (line 9) | public class City {
    method getId (line 32) | public Long getId() {
    method setId (line 36) | public void setId(Long id) {
    method getProvinceId (line 40) | public Long getProvinceId() {
    method setProvinceId (line 44) | public void setProvinceId(Long provinceId) {
    method getCityName (line 48) | public String getCityName() {
    method setCityName (line 52) | public void setCityName(String cityName) {
    method getDescription (line 56) | public String getDescription() {
    method setDescription (line 60) | public void setDescription(String description) {

FILE: springboot-webflux-3-mongodb/src/main/java/org/spring/springboot/handler/CityHandler.java
  class CityHandler (line 10) | @Component
    method CityHandler (line 15) | @Autowired
    method save (line 20) | public Mono<City> save(City city) {
    method findCityById (line 24) | public Mono<City> findCityById(Long id) {
    method findAllCity (line 29) | public Flux<City> findAllCity() {
    method modifyCity (line 34) | public Mono<City> modifyCity(City city) {
    method deleteCity (line 39) | public Mono<Long> deleteCity(Long id) {

FILE: springboot-webflux-3-mongodb/src/main/java/org/spring/springboot/webflux/controller/CityWebFluxController.java
  class CityWebFluxController (line 10) | @RestController
    method findCityById (line 17) | @GetMapping(value = "/{id}")
    method findAllCity (line 22) | @GetMapping()
    method saveCity (line 27) | @PostMapping()
    method modifyCity (line 32) | @PutMapping()
    method deleteCity (line 37) | @DeleteMapping(value = "/{id}")

FILE: springboot-webflux-4-thymeleaf/src/main/java/org/spring/springboot/Application.java
  class Application (line 11) | @SpringBootApplication
    method main (line 14) | public static void main(String[] args) {

FILE: springboot-webflux-4-thymeleaf/src/main/java/org/spring/springboot/dao/CityRepository.java
  class CityRepository (line 11) | @Repository
    method save (line 18) | public Long save(City city) {
    method findAll (line 25) | public Collection<City> findAll() {
    method findCityById (line 30) | public City findCityById(Long id) {
    method updateCity (line 34) | public Long updateCity(City city) {
    method deleteCity (line 39) | public Long deleteCity(Long id) {

FILE: springboot-webflux-4-thymeleaf/src/main/java/org/spring/springboot/domain/City.java
  class City (line 7) | public class City {
    method getId (line 29) | public Long getId() {
    method setId (line 33) | public void setId(Long id) {
    method getProvinceId (line 37) | public Long getProvinceId() {
    method setProvinceId (line 41) | public void setProvinceId(Long provinceId) {
    method getCityName (line 45) | public String getCityName() {
    method setCityName (line 49) | public void setCityName(String cityName) {
    method getDescription (line 53) | public String getDescription() {
    method setDescription (line 57) | public void setDescription(String description) {

FILE: springboot-webflux-4-thymeleaf/src/main/java/org/spring/springboot/handler/CityHandler.java
  class CityHandler (line 10) | @Component
    method CityHandler (line 15) | @Autowired
    method save (line 20) | public Mono<Long> save(City city) {
    method findCityById (line 24) | public Mono<City> findCityById(Long id) {
    method findAllCity (line 28) | public Flux<City> findAllCity() {
    method modifyCity (line 32) | public Mono<Long> modifyCity(City city) {
    method deleteCity (line 36) | public Mono<Long> deleteCity(Long id) {

FILE: springboot-webflux-4-thymeleaf/src/main/java/org/spring/springboot/webflux/controller/CityWebFluxController.java
  class CityWebFluxController (line 12) | @Controller
    method findCityById (line 19) | @GetMapping(value = "/{id}")
    method findAllCity (line 25) | @GetMapping()
    method saveCity (line 31) | @PostMapping()
    method modifyCity (line 37) | @PutMapping()
    method deleteCity (line 43) | @DeleteMapping(value = "/{id}")
    method hello (line 49) | @GetMapping("/hello")
    method listPage (line 60) | @GetMapping("/page/list")

FILE: springboot-webflux-5-thymeleaf-mongodb/src/main/java/org/spring/springboot/Application.java
  class Application (line 11) | @SpringBootApplication
    method main (line 14) | public static void main(String[] args) {

FILE: springboot-webflux-5-thymeleaf-mongodb/src/main/java/org/spring/springboot/dao/CityRepository.java
  type CityRepository (line 8) | @Repository
    method findByCityName (line 11) | Mono<City> findByCityName(String cityName);

FILE: springboot-webflux-5-thymeleaf-mongodb/src/main/java/org/spring/springboot/domain/City.java
  class City (line 7) | public class City {
    method getId (line 29) | public Long getId() {
    method setId (line 33) | public void setId(Long id) {
    method getProvinceId (line 37) | public Long getProvinceId() {
    method setProvinceId (line 41) | public void setProvinceId(Long provinceId) {
    method getCityName (line 45) | public String getCityName() {
    method setCityName (line 49) | public void setCityName(String cityName) {
    method getDescription (line 53) | public String getDescription() {
    method setDescription (line 57) | public void setDescription(String description) {

FILE: springboot-webflux-5-thymeleaf-mongodb/src/main/java/org/spring/springboot/handler/CityHandler.java
  class CityHandler (line 10) | @Component
    method CityHandler (line 15) | @Autowired
    method save (line 20) | public Mono<City> save(City city) {
    method findCityById (line 24) | public Mono<City> findCityById(Long id) {
    method findAllCity (line 29) | public Flux<City> findAllCity() {
    method modifyCity (line 34) | public Mono<City> modifyCity(City city) {
    method deleteCity (line 39) | public Mono<Long> deleteCity(Long id) {
    method getByCityName (line 44) | public Mono<City> getByCityName(String cityName) {

FILE: springboot-webflux-5-thymeleaf-mongodb/src/main/java/org/spring/springboot/webflux/controller/CityWebFluxController.java
  class CityWebFluxController (line 12) | @Controller
    method findCityById (line 19) | @GetMapping(value = "/{id}")
    method findAllCity (line 25) | @GetMapping()
    method saveCity (line 31) | @PostMapping()
    method modifyCity (line 37) | @PutMapping()
    method deleteCity (line 43) | @DeleteMapping(value = "/{id}")
    method listPage (line 52) | @GetMapping("/page/list")
    method getByCityName (line 59) | @GetMapping("/getByName")

FILE: springboot-webflux-6-redis/src/main/java/org/spring/springboot/Application.java
  class Application (line 11) | @SpringBootApplication
    method main (line 14) | public static void main(String[] args) {

FILE: springboot-webflux-6-redis/src/main/java/org/spring/springboot/domain/City.java
  class City (line 11) | public class City implements Serializable {
    method getId (line 36) | public Long getId() {
    method setId (line 40) | public void setId(Long id) {
    method getProvinceId (line 44) | public Long getProvinceId() {
    method setProvinceId (line 48) | public void setProvinceId(Long provinceId) {
    method getCityName (line 52) | public String getCityName() {
    method setCityName (line 56) | public void setCityName(String cityName) {
    method getDescription (line 60) | public String getDescription() {
    method setDescription (line 64) | public void setDescription(String description) {

FILE: springboot-webflux-6-redis/src/main/java/org/spring/springboot/webflux/controller/CityWebFluxController.java
  class CityWebFluxController (line 12) | @RestController
    method findCityById (line 19) | @GetMapping(value = "/{id}")
    method saveCity (line 32) | @PostMapping()
    method deleteCity (line 41) | @DeleteMapping(value = "/{id}")

FILE: springboot-webflux-6-redis/src/main/java/org/spring/springboot/webflux/controller/CityWebFluxReactiveController.java
  class CityWebFluxReactiveController (line 10) | @RestController
    method findCityById (line 17) | @GetMapping(value = "/{id}")
    method saveCity (line 25) | @PostMapping
    method deleteCity (line 32) | @DeleteMapping(value = "/{id}")

FILE: springboot-webflux-7-redis-cache/src/main/java/org/spring/springboot/Application.java
  class Application (line 10) | @SpringBootApplication
    method main (line 13) | public static void main(String[] args) {

FILE: springboot-webflux-7-redis-cache/src/main/java/org/spring/springboot/dao/CityRepository.java
  type CityRepository (line 7) | @Repository

FILE: springboot-webflux-7-redis-cache/src/main/java/org/spring/springboot/domain/City.java
  class City (line 11) | public class City implements Serializable {
    method getId (line 36) | public Long getId() {
    method setId (line 40) | public void setId(Long id) {
    method getProvinceId (line 44) | public Long getProvinceId() {
    method setProvinceId (line 48) | public void setProvinceId(Long provinceId) {
    method getCityName (line 52) | public String getCityName() {
    method setCityName (line 56) | public void setCityName(String cityName) {
    method getDescription (line 60) | public String getDescription() {
    method setDescription (line 64) | public void setDescription(String description) {
    method toString (line 68) | @Override

FILE: springboot-webflux-7-redis-cache/src/main/java/org/spring/springboot/handler/CityHandler.java
  class CityHandler (line 14) | @Component
    method CityHandler (line 24) | @Autowired
    method save (line 29) | public Mono<City> save(City city) {
    method findCityById (line 34) | public Mono<City> findCityById(Long id) {
    method findAllCity (line 64) | public Flux<City> findAllCity() {
    method modifyCity (line 68) | public Mono<City> modifyCity(City city) {
    method deleteCity (line 82) | public Mono<Long> deleteCity(Long id) {

FILE: springboot-webflux-7-redis-cache/src/main/java/org/spring/springboot/webflux/controller/CityWebFluxController.java
  class CityWebFluxController (line 10) | @RestController
    method findCityById (line 17) | @GetMapping(value = "/{id}")
    method findAllCity (line 22) | @GetMapping()
    method saveCity (line 27) | @PostMapping()
    method modifyCity (line 32) | @PutMapping()
    method deleteCity (line 37) | @DeleteMapping(value = "/{id}")

FILE: springboot-webflux-8-websocket/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: springboot-webflux-8-websocket/src/main/java/org/spring/springboot/config/WebSocketConfiguration.java
  class WebSocketConfiguration (line 16) | @Configuration
    method webSocketMapping (line 19) | @Autowired
    method handlerAdapter (line 31) | @Bean

FILE: springboot-webflux-8-websocket/src/main/java/org/spring/springboot/handler/EchoHandler.java
  class EchoHandler (line 9) | @Component
    method handle (line 11) | @Override

FILE: springboot-webflux-8-websocket/src/test/java/WSClient.java
  class WSClient (line 9) | public class WSClient {
    method main (line 12) | public static void main(final String[] args) {

FILE: springboot-webflux-9-test/src/main/java/org/spring/springboot/Application.java
  class Application (line 12) | @SpringBootApplication
    method main (line 15) | public static void main(String[] args) {

FILE: springboot-webflux-9-test/src/main/java/org/spring/springboot/dao/CityRepository.java
  type CityRepository (line 7) | @Repository

FILE: springboot-webflux-9-test/src/main/java/org/spring/springboot/domain/City.java
  class City (line 9) | public class City {
    method getId (line 32) | public Long getId() {
    method setId (line 36) | public void setId(Long id) {
    method getProvinceId (line 40) | public Long getProvinceId() {
    method setProvinceId (line 44) | public void setProvinceId(Long provinceId) {
    method getCityName (line 48) | public String getCityName() {
    method setCityName (line 52) | public void setCityName(String cityName) {
    method getDescription (line 56) | public String getDescription() {
    method setDescription (line 60) | public void setDescription(String description) {

FILE: springboot-webflux-9-test/src/main/java/org/spring/springboot/handler/CityHandler.java
  class CityHandler (line 10) | @Component
    method CityHandler (line 15) | @Autowired
    method save (line 20) | public Mono<City> save(City city) {
    method findCityById (line 24) | public Mono<City> findCityById(Long id) {
    method findAllCity (line 29) | public Flux<City> findAllCity() {
    method modifyCity (line 34) | public Mono<City> modifyCity(City city) {
    method deleteCity (line 39) | public Mono<Long> deleteCity(Long id) {

FILE: springboot-webflux-9-test/src/main/java/org/spring/springboot/webflux/controller/CityWebFluxController.java
  class CityWebFluxController (line 10) | @RestController
    method findCityById (line 17) | @GetMapping(value = "/{id}")
    method findAllCity (line 22) | @GetMapping()
    method saveCity (line 27) | @PostMapping()
    method modifyCity (line 32) | @PutMapping()
    method deleteCity (line 37) | @DeleteMapping(value = "/{id}")

FILE: springboot-webflux-9-test/src/test/java/org/spring/springboot/handler/CityHandlerTest.java
  class CityHandlerTest (line 18) | @RunWith(SpringRunner.class)
    method setup (line 27) | @BeforeClass
    method testSave (line 37) | @Test
Condensed preview — 312 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (369K chars).
[
  {
    "path": ".gitignore",
    "chars": 440,
    "preview": "*.class\n\n# Mobile Tools for Java (J2ME)\n.mtj.tmp/\n\n# Package Files #\n*.jar\n*.war\n*.ear\n\n# virtual machine crash logs, se"
  },
  {
    "path": "2-x-spring-boot-groovy/pom.xml",
    "chars": 1557,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "2-x-spring-boot-groovy/src/main/java/org/spring/springboot/Application.java",
    "chars": 437,
    "preview": "package org.spring.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoc"
  },
  {
    "path": "2-x-spring-boot-groovy/src/main/java/org/spring/springboot/filter/RouteRuleFilter.java",
    "chars": 1040,
    "preview": "package org.spring.springboot.filter;\n\nimport groovy.lang.Binding;\nimport groovy.lang.GroovyShell;\nimport groovy.lang.Sc"
  },
  {
    "path": "2-x-spring-boot-groovy/src/main/java/org/spring/springboot/web/GroovyScriptController.java",
    "chars": 978,
    "preview": "package org.spring.springboot.web;\n\nimport org.spring.springboot.filter.RouteRuleFilter;\nimport org.springframework.web."
  },
  {
    "path": "2-x-spring-boot-groovy/src/main/resources/application.properties",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "2-x-spring-boot-webflux-handling-errors/pom.xml",
    "chars": 1624,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/Application.java",
    "chars": 437,
    "preview": "package org.spring.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoc"
  },
  {
    "path": "2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/error/GlobalErrorAttributes.java",
    "chars": 1178,
    "preview": "package org.spring.springboot.error;\n\nimport org.springframework.boot.web.reactive.error.DefaultErrorAttributes;\nimport "
  },
  {
    "path": "2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/error/GlobalErrorWebExceptionHandler.java",
    "chars": 2134,
    "preview": "package org.spring.springboot.error;\n\nimport org.springframework.boot.autoconfigure.web.ResourceProperties;\nimport org.s"
  },
  {
    "path": "2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/error/GlobalException.java",
    "chars": 441,
    "preview": "package org.spring.springboot.error;\n\nimport org.springframework.http.HttpStatus;\nimport org.springframework.web.server."
  },
  {
    "path": "2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/handler/CityHandler.java",
    "chars": 967,
    "preview": "package org.spring.springboot.handler;\n\nimport org.spring.springboot.error.GlobalException;\nimport org.springframework.h"
  },
  {
    "path": "2-x-spring-boot-webflux-handling-errors/src/main/java/org/spring/springboot/router/CityRouter.java",
    "chars": 833,
    "preview": "package org.spring.springboot.router;\n\nimport org.spring.springboot.handler.CityHandler;\nimport org.springframework.cont"
  },
  {
    "path": "2-x-spring-boot-webflux-handling-errors/src/main/resources/application.properties",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "LICENSE",
    "chars": 11357,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "README.md",
    "chars": 4355,
    "preview": "[![Star History Chart](https://api.star-history.com/svg?repos=JeffLi1993/springboot-learning-example&type=Date)](https:/"
  },
  {
    "path": "chapter-1-spring-boot-quickstart/pom.xml",
    "chars": 2048,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "chapter-1-spring-boot-quickstart/src/main/java/demo/springboot/QuickStartApplication.java",
    "chars": 396,
    "preview": "package demo.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigu"
  },
  {
    "path": "chapter-1-spring-boot-quickstart/src/main/java/demo/springboot/web/HelloBookController.java",
    "chars": 510,
    "preview": "package demo.springboot.web;\n\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework."
  },
  {
    "path": "chapter-1-spring-boot-quickstart/src/main/java/demo/springboot/web/HelloController.java",
    "chars": 542,
    "preview": "package demo.springboot.web;\n\nimport org.springframework.stereotype.Controller;\nimport org.springframework.web.bind.anno"
  },
  {
    "path": "chapter-1-spring-boot-quickstart/src/main/resources/application.properties",
    "chars": 14,
    "preview": "server.port=-1"
  },
  {
    "path": "chapter-1-spring-boot-quickstart/src/test/java/demo/springboot/QuickStartApplicationTests.java",
    "chars": 1539,
    "preview": "package demo.springboot;\n\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.springframework.beans.fact"
  },
  {
    "path": "chapter-1-spring-boot-quickstart/src/test/resources/application.properties",
    "chars": 14,
    "preview": "server.port=-1"
  },
  {
    "path": "chapter-2-spring-boot-config/pom.xml",
    "chars": 2333,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "chapter-2-spring-boot-config/src/main/java/demo/springboot/ConfigApplication.java",
    "chars": 470,
    "preview": "package demo.springboot;\n\nimport com.spring4all.swagger.EnableSwagger2Doc;\nimport org.springframework.boot.SpringApplica"
  },
  {
    "path": "chapter-2-spring-boot-config/src/main/java/demo/springboot/config/BookComponent.java",
    "chars": 834,
    "preview": "package demo.springboot.config;\n\nimport org.springframework.boot.context.properties.ConfigurationProperties;\nimport org."
  },
  {
    "path": "chapter-2-spring-boot-config/src/main/java/demo/springboot/config/BookProperties.java",
    "chars": 685,
    "preview": "package demo.springboot.config;\n\nimport org.springframework.beans.factory.annotation.Value;\nimport org.springframework.s"
  },
  {
    "path": "chapter-2-spring-boot-config/src/main/java/demo/springboot/web/HelloBookController.java",
    "chars": 629,
    "preview": "package demo.springboot.web;\n\nimport demo.springboot.config.BookProperties;\nimport org.springframework.beans.factory.ann"
  },
  {
    "path": "chapter-2-spring-boot-config/src/main/resources/application-dev.properties",
    "chars": 102,
    "preview": "## \\u4E66\\u4FE1\\u606F\ndemo.book.name=[Spring Boot 2.x Core Action] From Dev\ndemo.book.writer=BYSocket\n"
  },
  {
    "path": "chapter-2-spring-boot-config/src/main/resources/application-prod.properties",
    "chars": 103,
    "preview": "## \\u4E66\\u4FE1\\u606F\ndemo.book.name=[Spring Boot 2.x Core Action] From Prod\ndemo.book.writer=BYSocket\n"
  },
  {
    "path": "chapter-2-spring-boot-config/src/main/resources/application.properties",
    "chars": 155,
    "preview": "## \\u4E66\\u4FE1\\u606F\ndemo.book.name=[Spring Boot 2.x Core Action]\ndemo.book.writer=BYSocket\ndemo.book.description=${dem"
  },
  {
    "path": "chapter-2-spring-boot-config/src/main/resources/application.yml",
    "chars": 97,
    "preview": "## 书信息\ndemo:\n    book:\n        name: 《Spring Boot 2.x 核心技术实战 - 上 基础篇》\n        writer: 泥瓦匠BYSocket"
  },
  {
    "path": "chapter-2-spring-boot-config/src/test/java/demo/springboot/ConfigApplicationTests.java",
    "chars": 934,
    "preview": "package demo.springboot;\n\nimport demo.springboot.config.BookComponent;\nimport demo.springboot.config.BookProperties;\nimp"
  },
  {
    "path": "chapter-3-spring-boot-web/pom.xml",
    "chars": 2038,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "chapter-3-spring-boot-web/src/main/java/demo/springboot/WebApplication.java",
    "chars": 382,
    "preview": "package demo.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigu"
  },
  {
    "path": "chapter-3-spring-boot-web/src/main/java/demo/springboot/domain/Book.java",
    "chars": 1337,
    "preview": "package demo.springboot.domain;\n\nimport java.io.Serializable;\n\n/**\n * Book 实体类\n *\n * Created by bysocket on 27/09/2017.\n"
  },
  {
    "path": "chapter-3-spring-boot-web/src/main/java/demo/springboot/service/BookService.java",
    "chars": 824,
    "preview": "package demo.springboot.service;\n\nimport demo.springboot.domain.Book;\n\nimport java.util.List;\n\n/**\n * Book 业务接口层\n *\n * C"
  },
  {
    "path": "chapter-3-spring-boot-web/src/main/java/demo/springboot/service/impl/BookServiceImpl.java",
    "chars": 1960,
    "preview": "package demo.springboot.service.impl;\n\nimport demo.springboot.domain.Book;\nimport demo.springboot.service.BookService;\ni"
  },
  {
    "path": "chapter-3-spring-boot-web/src/main/java/demo/springboot/web/BookController.java",
    "chars": 2509,
    "preview": "package demo.springboot.web;\n\nimport demo.springboot.domain.Book;\nimport demo.springboot.service.BookService;\nimport org"
  },
  {
    "path": "chapter-3-spring-boot-web/src/main/resources/application.properties",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "chapter-3-spring-boot-web/src/test/java/demo/springboot/WebApplicationTests.java",
    "chars": 329,
    "preview": "package demo.springboot;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.springframework.boot.test.c"
  },
  {
    "path": "chapter-3-spring-boot-web/src/test/java/demo/springboot/web/BookControllerTest.java",
    "chars": 6479,
    "preview": "package demo.springboot.web;\n\nimport com.fasterxml.jackson.databind.ObjectMapper;\nimport demo.springboot.WebApplication;"
  },
  {
    "path": "chapter-3-spring-boot-web/src/test/resources/application.properties",
    "chars": 16,
    "preview": "server.port=9090"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/pom.xml",
    "chars": 2916,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/ValidatingFormInputApplication.java",
    "chars": 1474,
    "preview": "package spring.boot.core;\n\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.beans.fac"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/domain/User.java",
    "chars": 1938,
    "preview": "package spring.boot.core.domain;\n\nimport org.hibernate.validator.constraints.NotEmpty;\n\nimport javax.persistence.Entity;"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/domain/UserRepository.java",
    "chars": 230,
    "preview": "package spring.boot.core.domain;\n\nimport org.springframework.data.jpa.repository.JpaRepository;\n\n/**\n * 用户持久层操作接口\n *\n * "
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/service/UserService.java",
    "chars": 341,
    "preview": "package spring.boot.core.service;\n\n\nimport spring.boot.core.domain.User;\n\nimport java.util.List;\n\n/**\n * User 业务层接口\n *\n "
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/service/impl/UserServiceImpl.java",
    "chars": 1389,
    "preview": "package spring.boot.core.service.impl;\n\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframew"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/main/java/spring/boot/core/web/UserController.java",
    "chars": 3212,
    "preview": "package spring.boot.core.web;\n\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/main/resources/application.properties",
    "chars": 338,
    "preview": "## 开启 H2 数据库\nspring.h2.console.enabled=true\n\n## 配置 H2 数据库连接信息\nspring.datasource.url=jdbc:h2:mem:testdb  \nspring.datasour"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/main/resources/static/css/default.css",
    "chars": 49,
    "preview": "/* contentDiv */\n.contentDiv {padding:20px 60px;}"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/main/resources/templates/userForm.html",
    "chars": 2805,
    "preview": "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n    <head>\n        <script type=\"text/javascript\" th:src=\"@{https://cdn.bootcss.com/"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/main/resources/templates/userList.html",
    "chars": 1730,
    "preview": "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n    <head>\n        <script type=\"text/javascript\" th:src=\"@{https://cdn.bootcss.com/"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/test/java/spring/boot/core/ValidatingFormInputApplicationTests.java",
    "chars": 346,
    "preview": "package spring.boot.core;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.springframework.boot.test."
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/test/java/spring/boot/core/web/UserControllerTest.java",
    "chars": 6325,
    "preview": "package spring.boot.core.web;\n\nimport com.fasterxml.jackson.annotation.JsonInclude;\nimport com.fasterxml.jackson.core.ty"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/test/resources/application.properties",
    "chars": 331,
    "preview": "## 开启 H2 数据库\nspring.h2.console.enabled=true\n\n## 配置 H2 数据库连接信息\nspring.datasource.url=jdbc:h2:mem:testdb\nspring.datasource"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/test/resources/static/css/default.css",
    "chars": 49,
    "preview": "/* contentDiv */\n.contentDiv {padding:20px 60px;}"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/test/resources/templates/userForm.html",
    "chars": 2805,
    "preview": "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n    <head>\n        <script type=\"text/javascript\" th:src=\"@{https://cdn.bootcss.com/"
  },
  {
    "path": "chapter-4-spring-boot-validating-form-input/src/test/resources/templates/userList.html",
    "chars": 1730,
    "preview": "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n    <head>\n        <script type=\"text/javascript\" th:src=\"@{https://cdn.bootcss.com/"
  },
  {
    "path": "chapter-4-spring-boot-web-thymeleaf/pom.xml",
    "chars": 2258,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/WebApplication.java",
    "chars": 382,
    "preview": "package demo.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigu"
  },
  {
    "path": "chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/domain/Book.java",
    "chars": 948,
    "preview": "package demo.springboot.domain;\n\nimport java.io.Serializable;\n\n/**\n * Book 实体类\n *\n * Created by bysocket on 30/09/2017.\n"
  },
  {
    "path": "chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/service/BookService.java",
    "chars": 626,
    "preview": "package demo.springboot.service;\n\nimport demo.springboot.domain.Book;\n\nimport java.util.List;\n\n/**\n * Book 业务接口层\n *\n * C"
  },
  {
    "path": "chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/service/impl/BookServiceImpl.java",
    "chars": 1082,
    "preview": "package demo.springboot.service.impl;\n\nimport demo.springboot.domain.Book;\nimport demo.springboot.service.BookService;\ni"
  },
  {
    "path": "chapter-4-spring-boot-web-thymeleaf/src/main/java/demo/springboot/web/BookController.java",
    "chars": 2591,
    "preview": "package demo.springboot.web;\n\nimport demo.springboot.domain.Book;\nimport demo.springboot.service.BookService;\nimport org"
  },
  {
    "path": "chapter-4-spring-boot-web-thymeleaf/src/main/resources/application.properties",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "chapter-4-spring-boot-web-thymeleaf/src/main/resources/static/css/default.css",
    "chars": 49,
    "preview": "/* contentDiv */\n.contentDiv {padding:20px 60px;}"
  },
  {
    "path": "chapter-4-spring-boot-web-thymeleaf/src/main/resources/templates/bookForm.html",
    "chars": 2167,
    "preview": "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>\n    <script type=\"text/javascript\" th:src=\"@{https://cdn.bootcss.com/jquery/3"
  },
  {
    "path": "chapter-4-spring-boot-web-thymeleaf/src/main/resources/templates/bookList.html",
    "chars": 1434,
    "preview": "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>\n    <script type=\"text/javascript\" th:src=\"@{https://cdn.bootcss.com/jquery/3"
  },
  {
    "path": "chapter-4-spring-boot-web-thymeleaf/src/test/java/demo/springboot/WebApplicationTests.java",
    "chars": 329,
    "preview": "package demo.springboot;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.springframework.boot.test.c"
  },
  {
    "path": "chapter-5-spring-boot-data-jpa/pom.xml",
    "chars": 2652,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/WebApplication.java",
    "chars": 382,
    "preview": "package demo.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigu"
  },
  {
    "path": "chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/domain/Book.java",
    "chars": 1087,
    "preview": "package demo.springboot.domain;\n\nimport javax.persistence.Entity;\nimport javax.persistence.GeneratedValue;\nimport javax."
  },
  {
    "path": "chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/domain/BookRepository.java",
    "chars": 233,
    "preview": "package demo.springboot.domain;\n\nimport org.springframework.data.jpa.repository.JpaRepository;\n\n/**\n * Book 数据持久层操作接口\n *"
  },
  {
    "path": "chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/service/BookService.java",
    "chars": 626,
    "preview": "package demo.springboot.service;\n\nimport demo.springboot.domain.Book;\n\nimport java.util.List;\n\n/**\n * Book 业务接口层\n *\n * C"
  },
  {
    "path": "chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/service/impl/BookServiceImpl.java",
    "chars": 1054,
    "preview": "package demo.springboot.service.impl;\n\nimport demo.springboot.domain.Book;\nimport demo.springboot.domain.BookRepository;"
  },
  {
    "path": "chapter-5-spring-boot-data-jpa/src/main/java/demo/springboot/web/BookController.java",
    "chars": 2591,
    "preview": "package demo.springboot.web;\n\nimport demo.springboot.domain.Book;\nimport demo.springboot.service.BookService;\nimport org"
  },
  {
    "path": "chapter-5-spring-boot-data-jpa/src/main/resources/application.properties",
    "chars": 41,
    "preview": "## 是否启动日志 SQL 语句\nspring.jpa.show-sql=true"
  },
  {
    "path": "chapter-5-spring-boot-data-jpa/src/main/resources/static/css/default.css",
    "chars": 49,
    "preview": "/* contentDiv */\n.contentDiv {padding:20px 60px;}"
  },
  {
    "path": "chapter-5-spring-boot-data-jpa/src/main/resources/templates/bookForm.html",
    "chars": 2167,
    "preview": "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>\n    <script type=\"text/javascript\" th:src=\"@{https://cdn.bootcss.com/jquery/3"
  },
  {
    "path": "chapter-5-spring-boot-data-jpa/src/main/resources/templates/bookList.html",
    "chars": 1433,
    "preview": "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>\n    <script type=\"text/javascript\" th:src=\"@{https://cdn.bootcss.com/jquery/3"
  },
  {
    "path": "chapter-5-spring-boot-data-jpa/src/test/java/demo/springboot/WebApplicationTests.java",
    "chars": 329,
    "preview": "package demo.springboot;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.springframework.boot.test.c"
  },
  {
    "path": "chapter-5-spring-boot-paging-sorting/pom.xml",
    "chars": 2541,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/PagingSortingApplication.java",
    "chars": 381,
    "preview": "package spring.boot.core;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfig"
  },
  {
    "path": "chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/domain/User.java",
    "chars": 1287,
    "preview": "package spring.boot.core.domain;\n\nimport javax.persistence.Entity;\nimport javax.persistence.GeneratedValue;\nimport javax"
  },
  {
    "path": "chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/domain/UserRepository.java",
    "chars": 252,
    "preview": "package spring.boot.core.domain;\n\nimport org.springframework.data.repository.PagingAndSortingRepository;\n\n/**\n * 用户持久层操作"
  },
  {
    "path": "chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/service/UserService.java",
    "chars": 492,
    "preview": "package spring.boot.core.service;\n\n\nimport org.springframework.data.domain.Page;\nimport org.springframework.data.domain."
  },
  {
    "path": "chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/service/impl/UserServiceImpl.java",
    "chars": 1133,
    "preview": "package spring.boot.core.service.impl;\n\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframew"
  },
  {
    "path": "chapter-5-spring-boot-paging-sorting/src/main/java/spring/boot/core/web/UserController.java",
    "chars": 1229,
    "preview": "package spring.boot.core.web;\n\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework"
  },
  {
    "path": "chapter-5-spring-boot-paging-sorting/src/main/resources/application.properties",
    "chars": 351,
    "preview": "## 是否显示 SQL 语句\nspring.jpa.show-sql=true\n\n## DATA WEB 相关配置 {@link SpringDataWebProperties}\n## 分页大小 默认为 20\nspring.data.web"
  },
  {
    "path": "chapter-5-spring-boot-paging-sorting/src/test/java/spring/boot/core/PagingSortingApplicationTests.java",
    "chars": 340,
    "preview": "package spring.boot.core;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.springframework.boot.test."
  },
  {
    "path": "pom.xml",
    "chars": 3075,
    "preview": "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xsi:schemaLo"
  },
  {
    "path": "spring-data-elasticsearch-crud/pom.xml",
    "chars": 1338,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/Application.java",
    "chars": 469,
    "preview": "package org.spring.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoc"
  },
  {
    "path": "spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/controller/CityRestController.java",
    "chars": 2633,
    "preview": "package org.spring.springboot.controller;\n\nimport org.spring.springboot.domain.City;\nimport org.spring.springboot.servic"
  },
  {
    "path": "spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/domain/City.java",
    "chars": 1123,
    "preview": "package org.spring.springboot.domain;\n\nimport org.springframework.data.elasticsearch.annotations.Document;\n\nimport java."
  },
  {
    "path": "spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/repository/CityRepository.java",
    "chars": 1542,
    "preview": "package org.spring.springboot.repository;\n\nimport org.spring.springboot.domain.City;\nimport org.springframework.data.dom"
  },
  {
    "path": "spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/service/CityService.java",
    "chars": 1037,
    "preview": "\npackage org.spring.springboot.service;\n\nimport org.spring.springboot.domain.City;\n\nimport java.util.List;\n\n/**\n * 城市 ES"
  },
  {
    "path": "spring-data-elasticsearch-crud/src/main/java/org/spring/springboot/service/impl/CityESServiceImpl.java",
    "chars": 1976,
    "preview": "package org.spring.springboot.service.impl;\n\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.spring."
  },
  {
    "path": "spring-data-elasticsearch-crud/src/main/resources/application.properties",
    "chars": 115,
    "preview": "# ES\nspring.data.elasticsearch.repositories.enabled = true\nspring.data.elasticsearch.cluster-nodes = 127.0.0.1:9300"
  },
  {
    "path": "spring-data-elasticsearch-query/pom.xml",
    "chars": 1340,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "spring-data-elasticsearch-query/src/main/java/org/spring/springboot/Application.java",
    "chars": 474,
    "preview": "package org.spring.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoc"
  },
  {
    "path": "spring-data-elasticsearch-query/src/main/java/org/spring/springboot/controller/CityRestController.java",
    "chars": 1336,
    "preview": "package org.spring.springboot.controller;\n\nimport org.spring.springboot.domain.City;\nimport org.spring.springboot.servic"
  },
  {
    "path": "spring-data-elasticsearch-query/src/main/java/org/spring/springboot/domain/City.java",
    "chars": 1123,
    "preview": "package org.spring.springboot.domain;\n\nimport org.springframework.data.elasticsearch.annotations.Document;\n\nimport java."
  },
  {
    "path": "spring-data-elasticsearch-query/src/main/java/org/spring/springboot/repository/CityRepository.java",
    "chars": 495,
    "preview": "package org.spring.springboot.repository;\n\nimport org.spring.springboot.domain.City;\nimport org.springframework.data.dom"
  },
  {
    "path": "spring-data-elasticsearch-query/src/main/java/org/spring/springboot/service/CityService.java",
    "chars": 511,
    "preview": "\npackage org.spring.springboot.service;\n\nimport org.spring.springboot.domain.City;\n\nimport java.util.List;\n\n/**\n * 城市 ES"
  },
  {
    "path": "spring-data-elasticsearch-query/src/main/java/org/spring/springboot/service/impl/CityESServiceImpl.java",
    "chars": 3694,
    "preview": "package org.spring.springboot.service.impl;\n\nimport org.elasticsearch.index.query.QueryBuilders;\nimport org.elasticsearc"
  },
  {
    "path": "spring-data-elasticsearch-query/src/main/resources/application.properties",
    "chars": 115,
    "preview": "# ES\nspring.data.elasticsearch.repositories.enabled = true\nspring.data.elasticsearch.cluster-nodes = 127.0.0.1:9300"
  },
  {
    "path": "springboot-configuration/pom.xml",
    "chars": 1102,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "springboot-configuration/src/main/java/org/spring/springboot/Application.java",
    "chars": 436,
    "preview": "package org.spring.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoc"
  },
  {
    "path": "springboot-configuration/src/main/java/org/spring/springboot/config/MessageConfiguration.java",
    "chars": 339,
    "preview": "package org.spring.springboot.config;\n\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.co"
  },
  {
    "path": "springboot-configuration/src/test/java/org/spring/springboot/config/MessageConfigurationTest.java",
    "chars": 874,
    "preview": "package org.spring.springboot.config;\n\nimport org.junit.Test;\nimport org.springframework.context.annotation.AnnotationCo"
  },
  {
    "path": "springboot-dubbo-client/pom.xml",
    "chars": 1630,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "springboot-dubbo-client/src/main/java/org/spring/springboot/ClientApplication.java",
    "chars": 774,
    "preview": "package org.spring.springboot;\n\nimport org.spring.springboot.dubbo.CityDubboConsumerService;\nimport org.springframework."
  },
  {
    "path": "springboot-dubbo-client/src/main/java/org/spring/springboot/domain/City.java",
    "chars": 1337,
    "preview": "package org.spring.springboot.domain;\n\nimport java.io.Serializable;\n\n/**\n * 城市实体类\n *\n * Created by bysocket on 07/02/201"
  },
  {
    "path": "springboot-dubbo-client/src/main/java/org/spring/springboot/dubbo/CityDubboConsumerService.java",
    "chars": 553,
    "preview": "package org.spring.springboot.dubbo;\n\nimport com.alibaba.dubbo.config.annotation.Reference;\nimport org.spring.springboot"
  },
  {
    "path": "springboot-dubbo-client/src/main/java/org/spring/springboot/dubbo/CityDubboService.java",
    "chars": 289,
    "preview": "package org.spring.springboot.dubbo;\n\nimport org.spring.springboot.domain.City;\n\n/**\n * 城市业务 Dubbo 服务层\n *\n * Created by "
  },
  {
    "path": "springboot-dubbo-client/src/main/resources/application.properties",
    "chars": 197,
    "preview": "## 避免和 server 工程端口冲突\nserver.port=8081\n\n## Dubbo 服务消费者配置\nspring.dubbo.application.name=consumer\nspring.dubbo.registry.add"
  },
  {
    "path": "springboot-dubbo-server/DubboProperties.md",
    "chars": 3641,
    "preview": "## Dubbo 配置\n# 扫描包路径\n<br>spring.dubbo.scan=org.<br>spring.<br>springboot.dubbo\n\n## Dubbo 应用配置\n// 应用名称\n<br>spring.dubbo.ap"
  },
  {
    "path": "springboot-dubbo-server/pom.xml",
    "chars": 1629,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "springboot-dubbo-server/src/main/java/org/spring/springboot/ServerApplication.java",
    "chars": 483,
    "preview": "package org.spring.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoc"
  },
  {
    "path": "springboot-dubbo-server/src/main/java/org/spring/springboot/domain/City.java",
    "chars": 1304,
    "preview": "package org.spring.springboot.domain;\n\nimport java.io.Serializable;\n\n/**\n * 城市实体类\n *\n * Created by bysocket on 07/02/201"
  },
  {
    "path": "springboot-dubbo-server/src/main/java/org/spring/springboot/dubbo/CityDubboService.java",
    "chars": 289,
    "preview": "package org.spring.springboot.dubbo;\n\nimport org.spring.springboot.domain.City;\n\n/**\n * 城市业务 Dubbo 服务层\n *\n * Created by "
  },
  {
    "path": "springboot-dubbo-server/src/main/java/org/spring/springboot/dubbo/impl/CityDubboServiceImpl.java",
    "chars": 536,
    "preview": "package org.spring.springboot.dubbo.impl;\n\nimport com.alibaba.dubbo.config.annotation.Service;\nimport org.spring.springb"
  },
  {
    "path": "springboot-dubbo-server/src/main/resources/application.properties",
    "chars": 224,
    "preview": "## Dubbo 服务提供者配置\nspring.dubbo.application.name=provider\nspring.dubbo.registry.address=zookeeper://127.0.0.1:2181\nspring."
  },
  {
    "path": "springboot-elasticsearch/pom.xml",
    "chars": 1326,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "springboot-elasticsearch/src/main/java/org/spring/springboot/Application.java",
    "chars": 471,
    "preview": "package org.spring.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoc"
  },
  {
    "path": "springboot-elasticsearch/src/main/java/org/spring/springboot/controller/CityRestController.java",
    "chars": 1085,
    "preview": "package org.spring.springboot.controller;\n\nimport org.spring.springboot.domain.City;\nimport org.spring.springboot.servic"
  },
  {
    "path": "springboot-elasticsearch/src/main/java/org/spring/springboot/domain/City.java",
    "chars": 1173,
    "preview": "package org.spring.springboot.domain;\n\nimport org.springframework.data.elasticsearch.annotations.Document;\n\nimport java."
  },
  {
    "path": "springboot-elasticsearch/src/main/java/org/spring/springboot/repository/CityRepository.java",
    "chars": 357,
    "preview": "package org.spring.springboot.repository;\n\nimport org.spring.springboot.domain.City;\nimport org.springframework.data.ela"
  },
  {
    "path": "springboot-elasticsearch/src/main/java/org/spring/springboot/service/CityService.java",
    "chars": 485,
    "preview": "\npackage org.spring.springboot.service;\n\nimport org.spring.springboot.domain.City;\nimport java.util.List;\n\npublic interf"
  },
  {
    "path": "springboot-elasticsearch/src/main/java/org/spring/springboot/service/impl/CityESServiceImpl.java",
    "chars": 2561,
    "preview": "package org.spring.springboot.service.impl;\n\nimport org.elasticsearch.index.query.QueryBuilders;\nimport org.elasticsearc"
  },
  {
    "path": "springboot-elasticsearch/src/main/resources/application.properties",
    "chars": 115,
    "preview": "# ES\nspring.data.elasticsearch.repositories.enabled = true\nspring.data.elasticsearch.cluster-nodes = 127.0.0.1:9300"
  },
  {
    "path": "springboot-freemarker/pom.xml",
    "chars": 2159,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "springboot-freemarker/src/main/java/org/spring/springboot/Application.java",
    "chars": 715,
    "preview": "package org.spring.springboot;\n\nimport org.mybatis.spring.annotation.MapperScan;\nimport org.spring.springboot.dao.CityDa"
  },
  {
    "path": "springboot-freemarker/src/main/java/org/spring/springboot/controller/CityController.java",
    "chars": 1044,
    "preview": "package org.spring.springboot.controller;\n\nimport org.spring.springboot.domain.City;\nimport org.spring.springboot.servic"
  },
  {
    "path": "springboot-freemarker/src/main/java/org/spring/springboot/dao/CityDao.java",
    "chars": 538,
    "preview": "package org.spring.springboot.dao;\n\nimport org.apache.ibatis.annotations.Param;\nimport org.spring.springboot.domain.City"
  },
  {
    "path": "springboot-freemarker/src/main/java/org/spring/springboot/domain/City.java",
    "chars": 946,
    "preview": "package org.spring.springboot.domain;\n\n/**\n * 城市实体类\n *\n * Created by bysocket on 07/02/2017.\n */\npublic class City {\n\n  "
  },
  {
    "path": "springboot-freemarker/src/main/java/org/spring/springboot/service/CityService.java",
    "chars": 711,
    "preview": "package org.spring.springboot.service;\n\nimport org.spring.springboot.domain.City;\n\nimport java.util.List;\n\n/**\n * 城市业务逻辑"
  },
  {
    "path": "springboot-freemarker/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java",
    "chars": 951,
    "preview": "package org.spring.springboot.service.impl;\n\nimport org.spring.springboot.dao.CityDao;\nimport org.spring.springboot.doma"
  },
  {
    "path": "springboot-freemarker/src/main/resources/application.properties",
    "chars": 766,
    "preview": "## 数据源配置\nspring.datasource.url=jdbc:mysql://127.0.0.1:3306/springbootdb?useUnicode=true&characterEncoding=utf8\nspring.da"
  },
  {
    "path": "springboot-freemarker/src/main/resources/mapper/CityMapper.xml",
    "chars": 1527,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org"
  },
  {
    "path": "springboot-freemarker/src/main/resources/web/city.ftl",
    "chars": 129,
    "preview": "<!DOCTYPE html>\n\n<html lang=\"en\">\n\n<body>\nCity: ${city.cityName}! <br>\nQ:Why I like? <br>\nA:${city.description}!\n</body>"
  },
  {
    "path": "springboot-freemarker/src/main/resources/web/cityList.ftl",
    "chars": 165,
    "preview": "<!DOCTYPE html>\n\n<html lang=\"en\">\n\n<body>\n<#list cityList as city>\n\nCity: ${city.cityName}! <br>\nQ:Why I like? <br>\nA:${"
  },
  {
    "path": "springboot-hbase/pom.xml",
    "chars": 1659,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "springboot-hbase/src/main/java/org/spring/springboot/Application.java",
    "chars": 471,
    "preview": "package org.spring.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoc"
  },
  {
    "path": "springboot-hbase/src/main/java/org/spring/springboot/controller/CityRestController.java",
    "chars": 916,
    "preview": "package org.spring.springboot.controller;\n\nimport org.spring.springboot.domain.City;\nimport org.spring.springboot.servic"
  },
  {
    "path": "springboot-hbase/src/main/java/org/spring/springboot/dao/CityRowMapper.java",
    "chars": 796,
    "preview": "package org.spring.springboot.dao;\n\nimport com.spring4all.spring.boot.starter.hbase.api.RowMapper;\nimport org.apache.had"
  },
  {
    "path": "springboot-hbase/src/main/java/org/spring/springboot/domain/City.java",
    "chars": 699,
    "preview": "package org.spring.springboot.domain;\n\n/**\n * 城市实体类\n *\n * Created by bysocket on 07/02/2017.\n */\npublic class City {\n\n  "
  },
  {
    "path": "springboot-hbase/src/main/java/org/spring/springboot/service/CityService.java",
    "chars": 336,
    "preview": "package org.spring.springboot.service;\n\nimport org.spring.springboot.domain.City;\n\nimport java.util.List;\n\n/**\n * 城市业务逻辑"
  },
  {
    "path": "springboot-hbase/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java",
    "chars": 1626,
    "preview": "package org.spring.springboot.service.impl;\n\nimport com.spring4all.spring.boot.starter.hbase.api.HbaseTemplate;\nimport o"
  },
  {
    "path": "springboot-hbase/src/main/resources/application.properties",
    "chars": 104,
    "preview": "## HBase 配置\nspring.data.hbase.quorum=xxx\nspring.data.hbase.rootDir=xxx\nspring.data.hbase.nodeParent=xxx\n"
  },
  {
    "path": "springboot-helloworld/pom.xml",
    "chars": 1096,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "springboot-helloworld/src/main/java/org/spring/springboot/Application.java",
    "chars": 471,
    "preview": "package org.spring.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoc"
  },
  {
    "path": "springboot-helloworld/src/main/java/org/spring/springboot/web/HelloWorldController.java",
    "chars": 386,
    "preview": "package org.spring.springboot.web;\n\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springfram"
  },
  {
    "path": "springboot-helloworld/src/test/java/org/spring/springboot/web/HelloWorldControllerTest.java",
    "chars": 390,
    "preview": "package org.spring.springboot.web;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.assertEquals;\n\n/**\n * Spring "
  },
  {
    "path": "springboot-mybatis/pom.xml",
    "chars": 1943,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "springboot-mybatis/src/main/java/org/spring/springboot/Application.java",
    "chars": 715,
    "preview": "package org.spring.springboot;\n\nimport org.mybatis.spring.annotation.MapperScan;\nimport org.spring.springboot.dao.CityDa"
  },
  {
    "path": "springboot-mybatis/src/main/java/org/spring/springboot/controller/CityRestController.java",
    "chars": 870,
    "preview": "package org.spring.springboot.controller;\n\nimport org.spring.springboot.domain.City;\nimport org.spring.springboot.servic"
  },
  {
    "path": "springboot-mybatis/src/main/java/org/spring/springboot/dao/CityDao.java",
    "chars": 344,
    "preview": "package org.spring.springboot.dao;\n\nimport org.apache.ibatis.annotations.Param;\nimport org.spring.springboot.domain.City"
  },
  {
    "path": "springboot-mybatis/src/main/java/org/spring/springboot/domain/City.java",
    "chars": 946,
    "preview": "package org.spring.springboot.domain;\n\n/**\n * 城市实体类\n *\n * Created by bysocket on 07/02/2017.\n */\npublic class City {\n\n  "
  },
  {
    "path": "springboot-mybatis/src/main/java/org/spring/springboot/service/CityService.java",
    "chars": 281,
    "preview": "package org.spring.springboot.service;\n\nimport org.spring.springboot.domain.City;\n\n/**\n * 城市业务逻辑接口类\n *\n * Created by bys"
  },
  {
    "path": "springboot-mybatis/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java",
    "chars": 565,
    "preview": "package org.spring.springboot.service.impl;\n\nimport org.spring.springboot.dao.CityDao;\nimport org.spring.springboot.doma"
  },
  {
    "path": "springboot-mybatis/src/main/resources/application.properties",
    "chars": 352,
    "preview": "## 数据源配置\nspring.datasource.url=jdbc:mysql://localhost:3306/springbootdb?useUnicode=true&characterEncoding=utf8\nspring.da"
  },
  {
    "path": "springboot-mybatis/src/main/resources/mapper/CityMapper.xml",
    "chars": 775,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org"
  },
  {
    "path": "springboot-mybatis-annotation/pom.xml",
    "chars": 1752,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "springboot-mybatis-annotation/src/main/java/org/spring/springboot/Application.java",
    "chars": 301,
    "preview": "package org.spring.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoc"
  },
  {
    "path": "springboot-mybatis-annotation/src/main/java/org/spring/springboot/controller/CityRestController.java",
    "chars": 828,
    "preview": "package org.spring.springboot.controller;\n\nimport org.spring.springboot.domain.City;\nimport org.spring.springboot.servic"
  },
  {
    "path": "springboot-mybatis-annotation/src/main/java/org/spring/springboot/dao/CityDao.java",
    "chars": 707,
    "preview": "package org.spring.springboot.dao;\n\nimport org.apache.ibatis.annotations.*;\nimport org.spring.springboot.domain.City;\n\n/"
  },
  {
    "path": "springboot-mybatis-annotation/src/main/java/org/spring/springboot/domain/City.java",
    "chars": 947,
    "preview": "package org.spring.springboot.domain;\n\n/**\n * 城市实体类\n *\n * Created by xchunzhao on 02/05/2017.\n */\npublic class City {\n\n "
  },
  {
    "path": "springboot-mybatis-annotation/src/main/java/org/spring/springboot/service/CityService.java",
    "chars": 282,
    "preview": "package org.spring.springboot.service;\n\nimport org.spring.springboot.domain.City;\n\n/**\n * 城市业务逻辑接口类\n *\n * Created by xch"
  },
  {
    "path": "springboot-mybatis-annotation/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java",
    "chars": 566,
    "preview": "package org.spring.springboot.service.impl;\n\nimport org.spring.springboot.dao.CityDao;\nimport org.spring.springboot.doma"
  },
  {
    "path": "springboot-mybatis-annotation/src/main/resources/application.properties",
    "chars": 241,
    "preview": "## 数据源配置\nspring.datasource.url=jdbc:mysql://139.224.14.39:3306/springbootdb?useUnicode=true&characterEncoding=utf8\nsprin"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/pom.xml",
    "chars": 2208,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/Application.java",
    "chars": 471,
    "preview": "package org.spring.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoc"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/config/ds/ClusterDataSourceConfig.java",
    "chars": 2448,
    "preview": "package org.spring.springboot.config.ds;\n\nimport com.alibaba.druid.pool.DruidDataSource;\nimport org.apache.ibatis.sessio"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/config/ds/MasterDataSourceConfig.java",
    "chars": 2542,
    "preview": "package org.spring.springboot.config.ds;\n\nimport com.alibaba.druid.pool.DruidDataSource;\nimport org.apache.ibatis.sessio"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/controller/UserRestController.java",
    "chars": 966,
    "preview": "package org.spring.springboot.controller;\n\nimport org.spring.springboot.domain.City;\nimport org.spring.springboot.domain"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/dao/cluster/CityDao.java",
    "chars": 405,
    "preview": "package org.spring.springboot.dao.cluster;\n\nimport org.apache.ibatis.annotations.Mapper;\nimport org.apache.ibatis.annota"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/dao/master/UserDao.java",
    "chars": 413,
    "preview": "package org.spring.springboot.dao.master;\n\nimport org.apache.ibatis.annotations.Mapper;\nimport org.apache.ibatis.annotat"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/domain/City.java",
    "chars": 976,
    "preview": "package org.spring.springboot.domain;\n\nimport java.io.Serializable;\n\n/**\n * 城市实体类\n *\n * Created by bysocket on 07/02/201"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/domain/User.java",
    "chars": 876,
    "preview": "package org.spring.springboot.domain;\n\n/**\n * 用户实体类\n *\n * Created by bysocket on 07/02/2017.\n */\npublic class User {\n\n  "
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/service/UserService.java",
    "chars": 347,
    "preview": "package org.spring.springboot.service;\n\nimport org.spring.springboot.domain.City;\nimport org.spring.springboot.domain.Us"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/java/org/spring/springboot/service/impl/UserServiceImpl.java",
    "chars": 833,
    "preview": "package org.spring.springboot.service.impl;\n\nimport org.spring.springboot.dao.cluster.CityDao;\nimport org.spring.springb"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/resources/application.properties",
    "chars": 493,
    "preview": "## master 数据源配置\nmaster.datasource.url=jdbc:mysql://localhost:3306/springbootdb?useUnicode=true&characterEncoding=utf8\nma"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/resources/mapper/cluster/CityMapper.xml",
    "chars": 783,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org"
  },
  {
    "path": "springboot-mybatis-mutil-datasource/src/main/resources/mapper/master/UserMapper.xml",
    "chars": 696,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org"
  },
  {
    "path": "springboot-mybatis-redis/pom.xml",
    "chars": 2317,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "springboot-mybatis-redis/src/main/java/org/spring/springboot/Application.java",
    "chars": 715,
    "preview": "package org.spring.springboot;\n\nimport org.mybatis.spring.annotation.MapperScan;\nimport org.spring.springboot.dao.CityDa"
  },
  {
    "path": "springboot-mybatis-redis/src/main/java/org/spring/springboot/controller/CityRestController.java",
    "chars": 1164,
    "preview": "package org.spring.springboot.controller;\n\nimport org.spring.springboot.domain.City;\nimport org.spring.springboot.servic"
  },
  {
    "path": "springboot-mybatis-redis/src/main/java/org/spring/springboot/dao/CityDao.java",
    "chars": 538,
    "preview": "package org.spring.springboot.dao;\n\nimport org.apache.ibatis.annotations.Param;\nimport org.spring.springboot.domain.City"
  },
  {
    "path": "springboot-mybatis-redis/src/main/java/org/spring/springboot/domain/City.java",
    "chars": 1337,
    "preview": "package org.spring.springboot.domain;\n\nimport java.io.Serializable;\n\n/**\n * 城市实体类\n *\n * Created by bysocket on 07/02/201"
  },
  {
    "path": "springboot-mybatis-redis/src/main/java/org/spring/springboot/service/CityService.java",
    "chars": 625,
    "preview": "package org.spring.springboot.service;\n\nimport org.spring.springboot.domain.City;\n\nimport java.util.List;\n\n/**\n * 城市业务逻辑"
  },
  {
    "path": "springboot-mybatis-redis/src/main/java/org/spring/springboot/service/impl/CityServiceImpl.java",
    "chars": 2661,
    "preview": "package org.spring.springboot.service.impl;\n\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.spring."
  },
  {
    "path": "springboot-mybatis-redis/src/main/resources/application.properties",
    "chars": 772,
    "preview": "## 数据源配置\nspring.datasource.url=jdbc:mysql://localhost:3306/springbootdb?useUnicode=true&characterEncoding=utf8\nspring.da"
  },
  {
    "path": "springboot-mybatis-redis/src/main/resources/mapper/CityMapper.xml",
    "chars": 1522,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org"
  },
  {
    "path": "springboot-mybatis-redis-annotation/pom.xml",
    "chars": 1969,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "springboot-mybatis-redis-annotation/src/main/java/org/spring/springboot/Application.java",
    "chars": 471,
    "preview": "package org.spring.springboot;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoc"
  },
  {
    "path": "springboot-mybatis-redis-annotation/src/main/java/org/spring/springboot/domain/City.java",
    "chars": 1559,
    "preview": "package org.spring.springboot.domain;\n\nimport java.io.Serializable;\n\n/**\n * 城市实体类\n *\n * Created by bysocket on 07/02/201"
  }
]

// ... and 112 more files (download for full content)

About this extraction

This page contains the full source code of the JeffLi1993/springboot-learning-example GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 312 files (312.8 KB), approximately 93.8k tokens, and a symbol index with 901 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!