跳至主要内容

帖子

目前显示的是 七月, 2016的博文

Upgrade to Spring Boot 1.4

Upgrade to Spring Boot 1.4 Spring Boot 1.4 is a big jump, and introduced lots of new test facilities and aligned with the new technology stack, such as Spring framework 4.3 and Hibernate 5.2 and Spring Security 4.1, etc.
Spring Boot 1.4New starter:spring-boot-starter-test Spring Boot 1.4 brings a new starter for test scope, named spring-boot-starter-test.
Use the following:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> Instead of:
<dependency> <groupId>com.jayway.jsonpath</groupId> <artifactId>json-path</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.hamcre…

Building REST APIs with Spring MVC

As stated in before posts, we are going to build a Blog system.
To demonstrate REST API, we use a simple Post entity to persist blog entries, and expose the CRUD operations via REST APIs to client applications. As a REST API consumer, the client applications could be a website, a desktop application, or a mobile application.
Following the REST API convention and HTTP protocol specification, the post APIs can be designed as the following table.
UriHttp MethodRequestResponseDescription/postsGET
200, [{'id':1, 'title'},{}]Get all posts/postsPOST{'title':'test title','content':'test content'}201Create a new post/posts/{id}GET
200, {'id':1, 'title'}Get a post by id/posts/{id}PUT{'title':'test title','content':'test content'}204Update a post/posts/{id}DELETE
204Delete a post Next, we begin to create the domain models: Post.
Modeling the blog application As planned in Overview, there are some d…