Springboot之学习第1天

1 学习计划

1.     Springboot和springmvc的关系

2.     第一个springboot程序的编写

3.     自定义属性配置

4.     Controller的使用

5.     Spring-data-jpa

6.     事务的管理

2   Springboot的特点

1.     简化配置

2.     是新一代的框架,未来的趋势

3.     微服务架构的基础


3   springboot的第一个应用

  1. 创建springboot工程


 

  1. 启动项目

编写helloController

@RestController

public class HelloController {

    @RequestMapping("/hello")
   
public String sayHello() {
       
return "hello spring boot";
   
}
}

4   属性配置


配置项目的端口和访问名称


使用官网推荐的配置文件 yml


绑定配置文件的内容到类的属性


 

优化之后

配置文件的属性切换



5 controller的使用


Restful:http://localhost:8082/demo10/users.do?id=1

http://localhost:8082/demo10/users/1

使用PathVariable实现restful风格的请求

@RequestMapping(value = "/haha/{id}",method = RequestMethod.POST)
public String haha(@PathVariable("id") Integer id) {
    return "id: "+id;
}

6  数据库的操作

restfulAPI的设计

请求类型

请求路径

功能

GET

/users

获取用户列表

POST

/users

创建一个用户

GET

/users/id

用过编号查询用户

PUT

/users/id

用过编号更新用户

DELETE

/users/id

用过编号删除用户

使用spring-data-jpa

配置


创建数据库,配置pojo

代码的编写



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值