Spring Boot 应用不是你自己 new 一堆对象到处传,而是交给容器统一调度。
Spring 容器 = 人事与调度中心
Controller 需要 Service
Service 需要 Repository
Repository 需要 DataSource最常见的角色分工:
@Controller/@RestController:窗口@Service:审批科@Repository:档案接口@Component:普通岗位@Configuration:制度和装配规则
Spring Boot 现在最推荐的注入方式,是构造器注入。