- Spring Boot 2.0 Cookbook(Second Edition)
- Alex Antonov
- 155字
- 2021-06-24 19:24:40
How to do it...
- We will start by adding another dependency to our build.gradle file in order to add the spring-boot-starter-data-rest artifact:
dependencies { ... compile("org.springframework.boot:spring-boot-starter-data-rest") ... }
- Now, let's create a new interface to define AuthorRepository in the src/main/java/com/example/bookpub/repository directory from the root of our project with the following content:
@RepositoryRestResource public interface AuthorRepository extends PagingAndSortingRepository<Author, Long> { }
- While we are at it—given how little code it takes—let's create the repository interfaces for the remaining entity models, PublisherRepository and ReviewerRepository by placing the files in the same package directory as AuthorRepository with the following content:
@RepositoryRestResource public interface PublisherRepository extends PagingAndSortingRepository<Publisher, Long> { }
Otherwise, you can use the following code instead of the preceding code:
@RepositoryRestResource public interface ReviewerRepository extends PagingAndSortingRepository<Reviewer, Long> { }
- Start the application by running ./gradlew clean bootRun
- After the application has started, open the browser and go to http://localhost:8080/authors and you should see the following response:
推薦閱讀
- DB29forLinux,UNIX,Windows數據庫管理認證指南
- 虛擬化與云計算
- 企業大數據系統構建實戰:技術、架構、實施與應用
- Libgdx Cross/platform Game Development Cookbook
- Lean Mobile App Development
- 金融商業算法建模:基于Python和SAS
- 深入淺出Greenplum分布式數據庫:原理、架構和代碼分析
- 計算機應用基礎教程上機指導與習題集(微課版)
- INSTANT Android Fragmentation Management How-to
- Google Cloud Platform for Developers
- 區域云計算和大數據產業發展:浙江樣板
- 大數據技術原理與應用:概念、存儲、處理、分析與應用
- 大數據數學基礎(R語言描述)
- Filecoin原理與實現
- 一類智能優化算法的改進及應用研究