Spring Boot可以非常简单的发布和调用RESTful web service,下面参考官方指导体验一下

1.首先访问 http://start.spring.io/ 生成Spring Boot基础项目

或者使用git clone https://github.com/spring-guides/gs-rest-service.git

 

这里使用Maven导入IDEA如下:

Spring Boot发布和调用RESTful web service

此时项目已经可以启动,但是没有任何功能,可以看到启动日志中嵌入tomcat的信息:

Spring Boot发布和调用RESTful web service

 

2.添加代码:

@JsonIgnoreProperties(ignoreUnknown = true)
public class Greeting {

    private final long id;
    private final String content;

    public Greeting(long id, String content) {
        this.id = id;
        this.content = content;
    }

    public long getId() {
        return id;
    }

    public String getContent() {
        return content;
    }
}
View Code

相关文章: