1.配置pom.xml文件的<parent>和<depencencies>,指定spring boot web依赖
org.springframework.boot spring-boot-starter-parent 1.4.1.RELEASE org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-tomcat com.wangxiaobao wxb-common 1.0-SNAPSHOT
2.AppMain(可以随意起名)类
@SpringBootApplicationpublic class AppMain{ public static void main(String[] args) { SpringApplication.run(AppMain.class, args); }}
3.RestController 实现简单的字符串倒序逻辑。
@RestControllerpublic class TestService{ @PostMapping(value = "/test") public String test(String input) { return new StringBuffer(input).reverse().toString(); }}
4.启动AppMain,Run as Java Application.测试成功(使用post-man):