快速搭建Spring-boot Demo
来源:互联网 发布:mac 自动更新 快捷键 编辑:程序博客网 时间:2024/06/10 02:06
快速搭建Spring-boot Demo
环境:
jdk: 1.8
ide: Spring Tool Suite
maven : 3.2 地址为阿里的maven仓库
步骤:
1 : file-->new--->Spring Starter Project
2:完成上述步骤后可以看到项目结构为:
再com.example包下新建两个包com.example.controller , com.example.entiry
Controller中代码如下:
@RestController@RequestMapping("/hello")public class ExampleController {@GetMapping("/home")//@GetMapping("/home")相当于@RequestMapping(value = "/home" ,method = requestMethod.Post)public Person home(){Person person = new Person();person.setId(222L);person.setName("张三");person.setAge(20);return person;}}Person基本结构:
package com.example.entity;public class Person {private Long id;private String name;private String add;private int age;public Long getId() {return id;}public void setId(Long id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getAdd() {return add;}public void setAdd(String add) {this.add = add;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}}
选中DemoApplication.java 右键run as Spring Boot App,启动完成后默认端口为8080
在浏览器中输入:http://localhost:8080/hello/home
如上显示,那么一个简单的Demo就完成了,关于controller和DemoApplication.java 类中的注解我们下面再一起学习
1 0
- 快速搭建Spring-boot Demo
- Spring boot快速搭建
- Spring boot 快速搭建
- Spring boot快速搭建
- 快速搭建Spring Boot项目
- Spring Boot 项目快速搭建
- spring boot的入门demo搭建记录
- 快速搭建Spring Boot+Spring MVC
- Spring Boot快速搭建Spring框架
- Spring Boot介绍 Spring Boot RESTfull API快速搭建
- 【Spring Boot教程】快速搭建spring boot项目工程
- Spring boot 快速入门 - 环境搭建
- Eclipse+Maven+Spring-boot快速搭建
- Spring Boot 快速搭建及简单演示
- WEB开发----Spring Boot项目快速搭建
- 使用Spring boot 快速 搭建 OAuth2 Server
- 快速搭建Spring boot CRUD-HelloWorld程序
- Spring-boot:快速搭建微服务框架
- mysql 语句大全
- c++实验4—编程序输出星号图
- 机器学习实例第二章:数据分析
- LeetCode 215 Kth Largest Element in an Array 含有各种快排对比
- c++第四次实验—输出星号图
- 快速搭建Spring-boot Demo
- table获取checkbox是否选中的几种方法
- 正则表达式验证由数字,大写字母,小写字母,特殊符,至少其中三种组成密码
- Appium环境搭建
- eclipse创建maven web
- poj 1035 字符串处理
- ubutun 12.04 安装 Docker CE
- c++作业5
- Error-Prone Criteria for new checks