1、创建spring bootproject
2、工程结构
3、修改maven LocalRepository地址
4、编写测试类HelloController
package com.glodon.springboot.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; /** * Created by zhangh-ag on 2017-06-11. */ /* RestController实现 @Target(value=TYPE) @Retention(value=RUNTIME) @Documented @Controller @ResponseBody public @interface RestController */ @RestController @RequestMapping(value = "/api/hello") public class HelloController { @RequestMapping(value = "/glodon", method = RequestMethod.GET) public String helloGlodon() { return "hello glodon!!!"; } /* GetMapping/PostMapping/PutMapping/DeleteMapping */ @GetMapping(value = "/glodon2") public String helloGlodon2() { return "hello glodon again !!!"; } }
5、运行测试类
更多: