IoC(Inversion of Control,控制反轉)
Spring 幫我們管理物件的建立與生命週期,開發者不用自己 new 物件。
物件由 Spring 容器建立與管理,降低程式耦合度。
DI(Dependency Injection,依賴注入)
Spring 在建立物件時,會自動把它需要的依賴物件注入進去。
Spring 常用 Annotation
Bean 管理:@Component、@Service、@Repository、@RestController
DI 注入:@Autowired、@Qualifier、@RequiredArgsConstructor
Web API:@RequestMapping、@GetMapping、@PathVariable、@RequestParam、@RequestBody
JPA:@Entity、@Table、@Id、@GeneratedValue、@OneToMany、@ManyToOne
其他:@Transactional、@Configuration、@Bean、@Value