Java梳理

梳理

1.@ResponseBody

return “hello world!”

当需要返回一个值的时候,需要使用到@ResponseBody

@RestController=@Controller+@ResponseBody

1.1没有Controller就不能写

@GetMapping("/hello")   

public String sayHello() 

{        

	return "Hello, world!";   

}

image-20240418104310027

2.层级 dao service controller

4层调用关系

  • 表示层(View\Web,前端页面展示) 调用 控制层(Controller)。
  • 控制层(Controller)调用业务层(Service)。
  • 业务层(Service)调用数据访问层(Dao)

image-20240418111335350

image-20240418111655914

3.控制反转、依赖注入、Bean对象

image-20240418111849888

分层解耦

内聚:软件中各个功能模块内部的功能联系

耦合:衡量软件中各个层或模块之间的依赖 关联的程度

image-20240408225457149

image-20240408225819119

image-20240408230000444

image-20240408230251285

image-20240408231159204

image-20240408231218424

@Component

以下三个的源都是@Component

@Controller @Service @Respository

image-20240408231845830

image-20240408232655914

image-20240408233123487

image-20240418162106607

image-20240408233814591

image-20240408234354922

image-20240408234950602

image-20240408235032622

image-20240408235129864

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值