spring boot开发REST接口
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):

spring boot开发REST接口的更多相关文章
- Spring Boot开发HTTPS协议的REST接口
Spring Boot开发HTTP的REST接口流程在前文中已经描述过,见<SpringBoot开发REST接口>. 如需要支持HTTPS,只需要在如上基础上进行设置.修改/resourc ...
- 使用Spring boot开发RestFul 风格项目PUT/DELETE方法不起作用
在使用Spring boot 开发restful 风格的项目,put.delete方法不起作用,解决办法. 实体类Student @Data public class Student { privat ...
- Spring Boot 开发微信公众号后台
Hello 各位小伙伴,松哥今天要和大家聊一个有意思的话题,就是使用 Spring Boot 开发微信公众号后台. 很多小伙伴可能注意到松哥的个人网站(http://www.javaboy.org)前 ...
- spring boot 开发环境搭建(Eclipse)
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
- Spring Boot开发RESTful接⼝服务及单元测试
Spring Boot开发RESTful接⼝服务及单元测试 常用注解解释说明: @Controller :修饰class,⽤来创建处理http请求的对象 @RestController :Spring ...
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
上篇博客使用Spring Boot开发Web项目我们简单介绍了使用如何使用Spring Boot创建一个使用了Thymeleaf模板引擎的Web项目,当然这还远远不够.今天我们再来看看如何给我们的We ...
- Spring Boot 开发系列一 开发环境的一些九九
从今天开始写这个Spring Boot 开发系列,我是第二周学习JAVA的,公司号称springboot把JAVA的开发提升到填空的能力,本人是NET转JAVA的,想看看这个填空的东西到底有多强.废话 ...
- 天天玩微信,Spring Boot 开发私有即时通信系统了解一下
1/ 概述 利用Spring Boot作为基础框架,Spring Security作为安全框架,WebSocket作为通信框架,实现点对点聊天和群聊天. 2/ 所需依赖 Spring Boot 版本 ...
- Spring Boot 之:接口参数校验
Spring Boot 之:接口参数校验,学习资料 网址 SpringBoot(八) JSR-303 数据验证(写的比较好) https://qq343509740.gitee.io/2018/07/ ...
随机推荐
- 什么是IaaS,PaaS和SaaS及其区别
云计算的三种服务模式:IaaS,PaaS和SaaS Infrastructure(基础设施)-as-a-Service,Platform(平台)-as-a-Service,Software(软件)-a ...
- Gym - 102059D 2018-2019 XIX Open Cup, Grand Prix of Korea D. Dumae 贪心+堆
题面 题意:有3e5个人排成一列,然后Li,Ri表示每个人可以站在[Li,Ri]中的一个,然后M(1e6)个限制条件,某个人一定要在某个人前面,求一种合法方案,无解输出-1 题解:首先可以想到对于限制 ...
- 基于Spark Streaming预测股票走势的例子(二)
上一篇博客中,已经对股票预测的例子做了简单的讲解,下面对其中的几个关键的技术点再作一些总结. 1.updateStateByKey 由于在1.6版本中有一个替代函数,据说效率比较高,所以作者就顺便研究 ...
- C# 截取字符串——
string strID ="NODE_aSDFghsdfgyuhjidfgh_45678" //得到_ 中间的数 int index = strID.IndexOf(" ...
- jsp动态网页开发基础
JSP基础语法 jsp页面元素构成 jsp页面组成部分有:指令,注释,静态内容,表达式,小脚本,声明. 1.表达式<%= %> 2.小脚本<% %> 3.声 ...
- cocos2dx实现单机版三国杀(一)
首先需要一个UI交互类 GameUI -layer 一个游戏驱动类,负责游戏逻辑的循环 暂时定为GameScene- scene GameScene obj 调用update 更新游戏,addch ...
- jQuery Tmpl使用
1.引入脚本 2.编写模板 2.1假设此时有一个,从后台一json格式发送来的数据 [{"tId":1,"tName":"张三"," ...
- 淘宝ip地址库接口会导致TTFB时间变长,网站打开速度变慢
前一段时间闲来无事发现别人的网站上有显示当前用户城市的功能,就自己也整了一个 这是淘宝ip地址库调用方法 然后问题就出现了,网站打开速度慢的要死 用F12发现是TTFB太慢,然后百度了,发现了问题的原 ...
- Lazarus 1.44升级到1.6 UTF8处理发生变化了
首先这里真的要强调一下,由于Freepascal升级到3.0后,FPC的内部将整个代码处理由AnsiString改为了UTF8编码(RTL with default codepage UTF-8). ...
- 关于Python中的类普通继承与super函数继承
关于Python中的类普通继承与super函数继承 1.super只能用于新式类 2.多重继承super可以保公共父类仅被执行一次 一.首先看下普通继承的写法 二.再看看super继承的写法 参考链接 ...