一、创建项目
创建的过程在上一篇文章中有介绍,这里就不赘述了,这篇博客着重介绍restful接口和postman测试web。
创建项目请戳这里:如何创建一个项目
1.代码及文件
在src—main—java—com.example.(你的文件名)下,新建包名(括号内表示文件名)
bean(Count)、controller(Controller)、manage(Manage)、service(Service);
如下:
Count代码
package com.example.myspringboot.bean;
public class Count {
private int count;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
}
Controller代码
package com.example.myspringboot.controller;
import com.example.myspringboot.bean.Count;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.myspringboot.service.myspringbootService;
@RestController
public