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