idea 创建一个 Etc_Bank_Follow项目
aliyun_settings.xml
user.home}/.m2/repository --> E:/anzhuang/aliyun_code true user.home}/.m2/plugin-registry.xml来管理plugin的版本,就设置为true,默认为false。 -->false false nexus-aliyun central Nexus aliyun http://maven.aliyun.com/nexus/content/groups/public/ default true 1.8 spring-milestone Spring Milestone Repository http://repo.spring.io/milestone true false default spring-snapshot Spring Snapshot Repository http://repo.spring.io/snapshot false true default
E:/anzhuang/aliyun_code
File — Settings — maven
添加访问接口
然后 在controller上面
内容为:
BookController.java
package com.etc.bank.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/books")
public class BookController {
@GetMapping
public String getById() {
System.out.println("springboot is running... ");
return "springboot is running...";
}
}
加入http post 请求 服务的源码
package com.etc.bank.controller;
import net.sf.json.JSONObject;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.UUID;
@RestController
@RequestMapping("/books")
public class BookController {
@GetMapping
public String getById() {
System.out.println("springboot is running... ");
return "springboot is running...";
}
@ResponseBody
@RequestMapping(value = "/postbook",method=RequestMethod.POST)
public String singlePaymentChk(ModelMap model, HttpServletRequest request, HttpServletResponse response) {
String uuid = UUID.randomUUID().toString();
JSONObject object=new JSONObject();
object.put("success", "000000");
object.put("msg", "msg: " + uuid);
object.put("data", "data: " + uuid);
String id = request.getParameter("id");
try {
} catch (Exception e) {
e.printStackTrace();
}
return object.toString();
}
}
postman请求
pom.xml 里面添加
net.sf.json-lib json-lib 2.4 jdk15



