You are on page 1of 7

Spring khác spring mvc

Như hibernate xài pojo


Thời gian làm nhỏ, ko depend nhiều
Ít xài spring data vì nó yếu hơn hibernate
Spring batch: xử lý khối lượng data lớn
Spring mobile yếu
Spring quản lý transaction tốt: quản lý trong code or file
xml

DI tách module ko depend


IoC : module lớn ko phụ thuộc module nhỏ
DI thừa kế IoC
Có 3 cách để 1 object thành bean
1 object bình thường có meta data => bean
Spring container: chứa các bean
Bean factory (interface): 1 implement duy 1, nó lazy
loading, ko ai xài.
Application contexts (interface): 5 implement, (xài đa
ngôn ngữ, tốt hơn), nó khởi tạo tất cả bean hết.

Object cấu hình trong beans.xml biến thành bean, bean


nằm trong spring ioc container, khởi tạo bean bằng bean
factory or application contexts
Annotation, system, annotation
Annotation web, xml web

Bean’s scope: 3 cái cuối cho web, default là singleton


Final immutable
Finally
Finalization : trước khi dọn rác làm cái gì đó
Java 5 trở lên autowired
3 chỗ autowired constructor, property…?
@Quanlifier
Có 2 loại DI: constructor, setter.
Java class làm sao thành bean spring: config meta data
3 cách: xml, annotation, java.
Bean Sống trong spring ioc Container
Khởi tạo Spring IoC Container có 2 cách: Bean Factory,
Application Context

5 loại của Application Contexts


Spring mạnh nhờ có IOC, AOP
AOP spring core xài được hay ko cũng ok
5 loại bean scope
@Component
– A generic stereotype that Spring will recognize as a
Spring-managed
component.
• @Repository
– This is a specialization of the @Component annotation
and it fulfills the idea
of the data access object.
• @Service
– This is a specialization of the @Component annotation
and it fulfills the idea
of a service layer.
• @Controller
– This is also a specialization of the @Component
annotation and normally is
used on a web context.
Muon xai bean thi lam sao?

You might also like