Spring-boot返回Json格式数据

来源:互联网 发布:淘宝手机壳评价 编辑:程序博客网 时间:2024/06/07 03:01

Spring-boot返回Json格式数据


Spring-boot返回json用到的注解为@RestController

  • 新建一个maven项目,编写pom.xml文件
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.3.3.RELEASE</version></parent><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin </artifactId></plugin></plugins></build>
  • 编写App.class(启动类)
  • 编写controller
  • 编写Person实体类 

  • 启动app.class

0 0