{"id":86530,"date":"2025-05-02T14:33:34","date_gmt":"2025-05-02T07:33:34","guid":{"rendered":"https:\/\/itviec1.uptech.vn\/?p=86530"},"modified":"2025-05-02T14:33:34","modified_gmt":"2025-05-02T07:33:34","slug":"spring-framework","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/spring-framework\/","title":{"rendered":"Spring Framework v\u00e0 h\u1ec7 sinh th\u00e1i v\u1eefng ch\u1eafc cho \u1ee9ng d\u1ee5ng Java"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">N\u1ed9i dung b\u00e0i vi\u1ebft<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itviec.com\/blog\/spring-framework\/#Spring_la_gi\" >Spring l\u00e0 g\u00ec?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itviec.com\/blog\/spring-framework\/#Uu_va_nhuoc_diem_cua_Spring\" >\u01afu v\u00e0 nh\u01b0\u1ee3c \u0111i\u1ec3m c\u1ee7a Spring<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itviec.com\/blog\/spring-framework\/#Cac_khai_niem_cot_loi_cua_Spring_Framework\" >C\u00e1c kh\u00e1i ni\u1ec7m c\u1ed1t l\u00f5i c\u1ee7a Spring Framework<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itviec.com\/blog\/spring-framework\/#Kien_truc_va_cac_module_chinh\" >Ki\u1ebfn tr\u00fac v\u00e0 c\u00e1c module ch\u00ednh<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/itviec.com\/blog\/spring-framework\/#He_sinh_thai_Spring_gom_nhung_thanh_phan_nao\" >H\u1ec7 sinh th\u00e1i Spring g\u1ed3m nh\u1eefng th\u00e0nh ph\u1ea7n n\u00e0o?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/itviec.com\/blog\/spring-framework\/#Cac_cau_hoi_thuong_gap_ve_Spring_framework\" >C\u00e1c c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 Spring framework<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/itviec.com\/blog\/spring-framework\/#Tong_ket\" >T\u1ed5ng k\u1ebft<\/a><\/li><\/ul><\/nav><\/div>\n<p><em><strong>Trong h\u1ec7 sinh th\u00e1i ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng Java, Spring Framework l\u00e0 m\u1ed9t framework m\u00e3 ngu\u1ed3n m\u1edf m\u1ea1nh m\u1ebd v\u00e0 \u0111\u01b0\u1ee3c \u01b0a chu\u1ed9ng b\u1eadc nh\u1ea5t hi\u1ec7n nay. M\u1ee5c ti\u00eau ch\u00ednh c\u1ee7a Spring l\u00e0 gi\u00fap \u0111\u01a1n gi\u1ea3n h\u00f3a qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n, gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean Java x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng d\u1ec5 b\u1ea3o tr\u00ec, d\u1ec5 ki\u1ec3m th\u1eed v\u00e0 c\u00f3 t\u00ednh module h\u00f3a cao. Spring kh\u00f4ng ch\u1ec9 l\u00e0 m\u1ed9t framework \u0111\u01a1n thu\u1ea7n, m\u00e0 c\u00f2n cung c\u1ea5p m\u1ed9t n\u1ec1n t\u1ea3ng to\u00e0n di\u1ec7n v\u00e0 linh ho\u1ea1t cho vi\u1ec7c ph\u00e1t tri\u1ec3n t\u1eeb c\u00e1c \u1ee9ng d\u1ee5ng web \u0111\u01a1n gi\u1ea3n \u0111\u1ebfn c\u00e1c h\u1ec7 th\u1ed1ng doanh nghi\u1ec7p ph\u1ee9c t\u1ea1p. B\u00e0i vi\u1ebft n\u00e0y s\u1ebd gi\u00fap b\u1ea1n hi\u1ec3u r\u00f5 to\u00e0n b\u1ed9 h\u1ec7 sinh th\u00e1i n\u00e0y!<\/strong><\/em><\/p>\n<p>\u0110\u1ecdc b\u00e0i vi\u1ebft n\u00e0y \u0111\u1ec3 hi\u1ec3u th\u00eam v\u1ec1:<\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">L\u1ecbch s\u1eed ph\u00e1t tri\u1ec3n v\u00e0 c\u00e1c \u1ee9ng d\u1ee5ng ph\u1ed5 bi\u1ebfn hi\u1ec7n nay<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e1c kh\u00e1i ni\u1ec7m c\u1ed1t l\u00f5i c\u1ee7a Spring<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Ki\u1ebfn tr\u00fac v\u00e0 c\u00e1c module ch\u00ednh<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">H\u1ec7 sinh th\u00e1i c\u1ee7a Spring<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Spring_la_gi\"><\/span><b>Spring l\u00e0 g\u00ec?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>L\u1ecbch s\u1eed v\u00e0 ngu\u1ed3n g\u1ed1c<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Spring Framework ra \u0111\u1eddi v\u00e0o kho\u1ea3ng n\u0103m 2002-2003, kh\u1edfi ngu\u1ed3n t\u1eeb nh\u1eefng \u00fd t\u01b0\u1edfng \u0111\u01b0\u1ee3c tr\u00ecnh b\u00e0y b\u1edfi <\/span><a href=\"https:\/\/en.wikipedia.org\/wiki\/Rod_Johnson_(programmer)\" target=\"_blank\" rel=\"noopener\"><b>Rod Johnson<\/b><\/a><span style=\"font-weight: 400;\"> trong cu\u1ed1n s\u00e1ch <\/span><a href=\"https:\/\/www.amazon.com\/Expert-One-One-Design-Development\/dp\/0764543857\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">&#8220;Expert One-on-One J2EE Design and Development&#8221;<\/span><\/a><span style=\"font-weight: 400;\">. V\u00e0o th\u1eddi \u0111i\u1ec3m \u0111\u00f3, vi\u1ec7c ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng doanh nghi\u1ec7p v\u1edbi <\/span><a href=\"https:\/\/www.oracle.com\/java\/technologies\/enterprise-javabeans-technology.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Enterprise JavaBeans (EJB)<\/span><\/a><span style=\"font-weight: 400;\"> phi\u00ean b\u1ea3n 2.x b\u1ecb xem l\u00e0 qu\u00e1 ph\u1ee9c t\u1ea1p, n\u1eb7ng n\u1ec1 v\u00e0 \u0111\u00f2i h\u1ecfi nhi\u1ec1u c\u1ea5u h\u00ecnh r\u01b0\u1eddm r\u00e0. Spring \u0111\u01b0\u1ee3c t\u1ea1o ra nh\u01b0 m\u1ed9t gi\u1ea3i ph\u00e1p thay th\u1ebf nh\u1eb9 nh\u00e0ng, linh ho\u1ea1t h\u01a1n, t\u1eadp trung v\u00e0o vi\u1ec7c s\u1eed d\u1ee5ng c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng Java \u0111\u01a1n gi\u1ea3n (POJO &#8211; Plain Old Java Object), nh\u1eb1m gi\u1ea3i quy\u1ebft nh\u1eefng nh\u01b0\u1ee3c \u0111i\u1ec3m c\u1ed1 h\u1eefu c\u1ee7a EJB 2.x v\u00e0 \u0111\u01a1n gi\u1ea3n h\u00f3a vi\u1ec7c ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng Java EE.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 hi\u1ec3u r\u00f5 v\u1ec1 Spring, ch\u00fang ta c\u1ea7n nh\u00ecn nh\u1eadn n\u00f3 kh\u00f4ng ch\u1ec9 nh\u01b0 m\u1ed9t framework th\u00f4ng th\u01b0\u1eddng.\u00a0<\/span><\/p>\n<p><b>Spring Framework th\u1ef1c ch\u1ea5t l\u00e0 m\u1ed9t framework \u1ee9ng d\u1ee5ng m\u00e3 ngu\u1ed3n m\u1edf to\u00e0n di\u1ec7n v\u00e0 \u0111\u1ed3ng th\u1eddi l\u00e0 m\u1ed9t container qu\u1ea3n l\u00fd <\/b><a href=\"https:\/\/www.baeldung.com\/inversion-control-and-dependency-injection-in-spring\" target=\"_blank\" rel=\"noopener\"><b>Inversion of Control (IoC)<\/b><\/a><b> cho n\u1ec1n t\u1ea3ng Java.<\/b><\/p>\n<p><span style=\"font-weight: 400;\">N\u00f3i m\u1ed9t c\u00e1ch \u0111\u01a1n gi\u1ea3n h\u01a1n, Spring framework l\u00e0:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u00e0 m\u1ed9t Framework \u1ee9ng d\u1ee5ng:<\/b><span style=\"font-weight: 400;\"> Spring cung c\u1ea5p m\u1ed9t b\u1ed9 c\u00f4ng c\u1ee5, th\u01b0 vi\u1ec7n v\u00e0 c\u1ea5u tr\u00fac n\u1ec1n t\u1ea3ng phong ph\u00fa \u0111\u1ec3 x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng Java m\u1ed9t c\u00e1ch c\u00f3 h\u1ec7 th\u1ed1ng. N\u00f3 \u0111\u1ecbnh ngh\u0129a c\u00e1c quy \u01b0\u1edbc v\u00e0 cung c\u1ea5p c\u00e1c gi\u1ea3i ph\u00e1p s\u1eb5n c\u00f3 cho nh\u1eefng v\u1ea5n \u0111\u1ec1 ph\u1ed5 bi\u1ebfn trong ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m (nh\u01b0 truy c\u1eadp d\u1eef li\u1ec7u, qu\u1ea3n l\u00fd giao d\u1ecbch, x\u1eed l\u00fd web request&#8230;).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u00e0 m\u1ed9t IoC Container:<\/b><span style=\"font-weight: 400;\"> \u0110\u00e2y l\u00e0 tr\u00e1i tim c\u1ee7a Spring. Thay v\u00ec l\u1eadp tr\u00ecnh vi\u00ean t\u1ef1 t\u1ea1o v\u00e0 qu\u1ea3n l\u00fd c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng (beans) v\u00e0 m\u1ed1i quan h\u1ec7 ph\u1ee5 thu\u1ed9c gi\u1eefa ch\u00fang, Spring Container s\u1ebd \u0111\u1ea3m nh\u1eadn vi\u1ec7c n\u00e0y (\u0111\u1ea3o ng\u01b0\u1ee3c quy\u1ec1n \u0111i\u1ec1u khi\u1ec3n &#8211; Inversion of Control). N\u00f3 &#8220;ti\u00eam&#8221; (inject) c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng ph\u1ee5 thu\u1ed9c v\u00e0o \u0111\u1ed1i t\u01b0\u1ee3ng c\u1ea7n ch\u00fang (Dependency Injection &#8211; DI). \u0110i\u1ec1u n\u00e0y gi\u00fap gi\u1ea3m \u0111\u00e1ng k\u1ec3 s\u1ef1 k\u1ebft d\u00ednh (coupling) gi\u1eefa c\u00e1c th\u00e0nh ph\u1ea7n, l\u00e0m cho code d\u1ec5 qu\u1ea3n l\u00fd, d\u1ec5 m\u1edf r\u1ed9ng v\u00e0 \u0111\u1eb7c bi\u1ec7t l\u00e0 d\u1ec5 ki\u1ec3m th\u1eed (testable) h\u01a1n.<\/span><\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-86533\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/05\/spring-1-vippro.png\" alt=\"spring - itviec blog\" width=\"1027\" height=\"854\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/05\/spring-1-vippro.png 1027w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/05\/spring-1-vippro-300x249.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/05\/spring-1-vippro-768x639.png 640w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/05\/spring-1-vippro-200x166.png 200w\" sizes=\"auto, (max-width: 1027px) 100vw, 1027px\" \/><\/p>\n<p><em><span style=\"font-weight: 400;\">H\u00ecnh \u1ea3nh m\u00f4 t\u1ea3 nguy\u00ean l\u00fd ho\u1ea1t \u0111\u1ed9ng c\u1ee7a<\/span><b>\u00a0<\/b><b>Inversion of Control (IoC).<\/b><\/em><\/p>\n<h3><b>C\u00e1c tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng Spring ph\u1ed5 bi\u1ebfn<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Nh\u1edd t\u00ednh linh ho\u1ea1t v\u00e0 h\u1ec7 sinh th\u00e1i r\u1ed9ng l\u1edbn, Spring \u0111\u01b0\u1ee3c \u1ee9ng d\u1ee5ng trong h\u1ea7u h\u1ebft m\u1ecdi l\u0129nh v\u1ef1c ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng Java hi\u1ec7n \u0111\u1ea1i:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>X\u00e2y d\u1ef1ng \u1ee9ng d\u1ee5ng Web v\u00e0 RESTful APIs:<\/b><span style=\"font-weight: 400;\"> \u0110\u00e2y l\u00e0 \u1ee9ng d\u1ee5ng ph\u1ed5 bi\u1ebfn nh\u1ea5t, s\u1eed d\u1ee5ng c\u00e1c module nh\u01b0 Spring MVC ho\u1eb7c Spring WebFlux (cho \u1ee9ng d\u1ee5ng ph\u1ea3n \u1ee9ng &#8211; reactive).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ph\u00e1t tri\u1ec3n ki\u1ebfn tr\u00fac Microservices:<\/b><span style=\"font-weight: 400;\"> Spring Boot v\u00e0 Spring Cloud cung c\u1ea5p m\u1ed9t b\u1ed9 c\u00f4ng c\u1ee5 c\u1ef1c k\u1ef3 m\u1ea1nh m\u1ebd \u0111\u1ec3 x\u00e2y d\u1ef1ng, c\u1ea5u h\u00ecnh, v\u00e0 qu\u1ea3n l\u00fd c\u00e1c microservices.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Truy c\u1eadp d\u1eef li\u1ec7u:<\/b><span style=\"font-weight: 400;\"> Spring Data \u0111\u01a1n gi\u1ea3n h\u00f3a vi\u1ec7c t\u01b0\u01a1ng t\u00e1c v\u1edbi nhi\u1ec1u lo\u1ea1i c\u01a1 s\u1edf d\u1eef li\u1ec7u, c\u1ea3 SQL (th\u00f4ng qua JPA, JDBC) v\u00e0 NoSQL (MongoDB, Redis, Cassandra&#8230;).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>B\u1ea3o m\u1eadt \u1ee9ng d\u1ee5ng:<\/b><span style=\"font-weight: 400;\"> Spring Security l\u00e0 gi\u1ea3i ph\u00e1p h\u00e0ng \u0111\u1ea7u \u0111\u1ec3 x\u1eed l\u00fd x\u00e1c th\u1ef1c (authentication) v\u00e0 ph\u00e2n quy\u1ec1n (authorization).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>X\u1eed l\u00fd t\u00e1c v\u1ee5 n\u1ec1n v\u00e0 Batch Processing:<\/b><span style=\"font-weight: 400;\"> Spring Batch cung c\u1ea5p m\u1ed9t framework m\u1ea1nh m\u1ebd \u0111\u1ec3 x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng x\u1eed l\u00fd d\u1eef li\u1ec7u l\u1edbn theo l\u00f4.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u00edch h\u1ee3p h\u1ec7 th\u1ed1ng:<\/b><span style=\"font-weight: 400;\"> Spring Integration h\u1ed7 tr\u1ee3 k\u1ebft n\u1ed1i v\u00e0 giao ti\u1ebfp gi\u1eefa c\u00e1c h\u1ec7 th\u1ed1ng kh\u00e1c nhau th\u00f4ng qua c\u00e1c m\u1eabu t\u00edch h\u1ee3p doanh nghi\u1ec7p (Enterprise Integration Patterns).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng Cloud-Native:<\/b><span style=\"font-weight: 400;\"> Spring d\u1ec5 d\u00e0ng t\u00edch h\u1ee3p v\u00e0 tri\u1ec3n khai tr\u00ean c\u00e1c n\u1ec1n t\u1ea3ng \u0111\u00e1m m\u00e2y.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Ch\u00fang ta s\u1ebd t\u00ecm hi\u1ec3u chi ti\u1ebft v\u1ec1 c\u00e1c module v\u00e0 th\u00e0nh ph\u1ea7n trong h\u1ec7 sinh th\u00e1i Spring k\u1ec3 tr\u00ean \u1edf ph\u1ea7n b\u00ean d\u01b0\u1edbi c\u1ee7a b\u00e0i vi\u1ebft.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Uu_va_nhuoc_diem_cua_Spring\"><\/span><b>\u01afu v\u00e0 nh\u01b0\u1ee3c \u0111i\u1ec3m c\u1ee7a Spring<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Nh\u01b0 m\u1ecdi c\u00f4ng ngh\u1ec7 kh\u00e1c, Spring c\u0169ng c\u00f3 nh\u1eefng \u0111i\u1ec3m m\u1ea1nh v\u00e0 \u0111i\u1ec3m y\u1ebfu ri\u00eang:<\/span><\/p>\n<h3><b>\u01afu \u0111i\u1ec3m<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Gi\u1ea3m s\u1ef1 ph\u1ee5 thu\u1ed9c (Loose Coupling):<\/b><span style=\"font-weight: 400;\"> Nh\u1edd c\u01a1 ch\u1ebf Dependency Injection (DI).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u1eadp tr\u00ecnh h\u01b0\u1edbng kh\u00eda c\u1ea1nh (AOP):<\/b><span style=\"font-weight: 400;\"> Gi\u00fap t\u00e1ch bi\u1ec7t c\u00e1c m\u1ed1i quan t\u00e2m chung (logging, security, transaction).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>\u0110\u01a1n gi\u1ea3n h\u00f3a boilerplate code:<\/b><span style=\"font-weight: 400;\"> Cung c\u1ea5p c\u00e1c template (JdbcTemplate, JmsTemplate&#8230;) gi\u00fap gi\u1ea3m m\u00e3 l\u1eb7p.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u0103ng kh\u1ea3 n\u0103ng ki\u1ec3m th\u1eed (Testability):<\/b><span style=\"font-weight: 400;\"> Code \u00edt ph\u1ee5 thu\u1ed9c gi\u00fap vi\u1ebft Unit Test d\u1ec5 d\u00e0ng h\u01a1n.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u00ednh Module h\u00f3a:<\/b><span style=\"font-weight: 400;\"> Cho ph\u00e9p ch\u1ecdn l\u1ef1a v\u00e0 s\u1eed d\u1ee5ng nh\u1eefng ph\u1ea7n c\u1ea7n thi\u1ebft.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>H\u1ec7 sinh th\u00e1i c\u1ef1c k\u1ef3 phong ph\u00fa:<\/b><span style=\"font-weight: 400;\"> Spring Boot, Spring Cloud, Spring Data, Spring Security&#8230; \u0111\u00e1p \u1ee9ng h\u1ea7u h\u1ebft nhu c\u1ea7u.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u00edch h\u1ee3p m\u1ea1nh m\u1ebd:<\/b><span style=\"font-weight: 400;\"> D\u1ec5 d\u00e0ng k\u1ebft h\u1ee3p v\u1edbi c\u00e1c c\u00f4ng ngh\u1ec7 v\u00e0 framework Java kh\u00e1c.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>C\u1ed9ng \u0111\u1ed3ng l\u1edbn v\u00e0 t\u00e0i li\u1ec7u t\u1ed1t:<\/b><span style=\"font-weight: 400;\"> D\u1ec5 d\u00e0ng t\u00ecm ki\u1ebfm s\u1ef1 gi\u00fap \u0111\u1ee1 v\u00e0 h\u1ecdc h\u1ecfi.<\/span><\/li>\n<\/ul>\n<h3><b>Nh\u01b0\u1ee3c \u0111i\u1ec3m<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ph\u1ee9c t\u1ea1p v\u1edbi ng\u01b0\u1eddi m\u1edbi:<\/b><span style=\"font-weight: 400;\"> H\u1ec7 sinh th\u00e1i l\u1edbn v\u00e0 nhi\u1ec1u kh\u00e1i ni\u1ec7m (IoC, DI, AOP, Proxy&#8230;) c\u00f3 th\u1ec3 g\u00e2y kh\u00f3 kh\u0103n cho ng\u01b0\u1eddi m\u1edbi b\u1eaft \u0111\u1ea7u.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>C\u1ea5u h\u00ecnh ph\u1ee9c t\u1ea1p (tr\u01b0\u1edbc Spring Boot):<\/b><span style=\"font-weight: 400;\"> C\u00e1c phi\u00ean b\u1ea3n Spring tr\u01b0\u1edbc \u0111\u00e2y ho\u1eb7c c\u00e1c d\u1ef1 \u00e1n kh\u00f4ng d\u00f9ng Spring Boot c\u00f3 th\u1ec3 y\u00eau c\u1ea7u c\u1ea5u h\u00ecnh XML ho\u1eb7c Java-based kh\u00e1 d\u00e0i d\u00f2ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Kh\u00f3 g\u1ee1 l\u1ed7i trong m\u1ed9t s\u1ed1 tr\u01b0\u1eddng h\u1ee3p:<\/b><span style=\"font-weight: 400;\"> C\u00e1c c\u01a1 ch\u1ebf &#8220;\u1ea9n&#8221; nh\u01b0 auto-configuration c\u1ee7a Spring Boot \u0111\u00f4i khi khi\u1ebfn vi\u1ec7c truy v\u1ebft v\u00e0 g\u1ee1 l\u1ed7i tr\u1edf n\u00ean ph\u1ee9c t\u1ea1p h\u01a1n n\u1ebfu ch\u01b0a hi\u1ec3u r\u00f5 c\u00e1ch ho\u1ea1t \u0111\u1ed9ng b\u00ean trong.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Overhead ti\u1ec1m \u1ea9n:<\/b><span style=\"font-weight: 400;\"> V\u1edbi c\u00e1c \u1ee9ng d\u1ee5ng c\u1ef1c k\u1ef3 nh\u1ecf v\u00e0 \u0111\u01a1n gi\u1ea3n, vi\u1ec7c s\u1eed d\u1ee5ng Spring c\u00f3 th\u1ec3 mang l\u1ea1i m\u1ed9t ch\u00fat overhead kh\u00f4ng c\u1ea7n thi\u1ebft v\u1ec1 t\u00e0i nguy\u00ean v\u00e0 k\u00edch th\u01b0\u1edbc g\u00f3i tri\u1ec3n khai.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Cac_khai_niem_cot_loi_cua_Spring_Framework\"><\/span><b>C\u00e1c kh\u00e1i ni\u1ec7m c\u1ed1t l\u00f5i c\u1ee7a Spring Framework<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 l\u00e0m ch\u1ee7 Spring Framework, vi\u1ec7c n\u1eafm v\u1eefng c\u00e1c kh\u00e1i ni\u1ec7m n\u1ec1n t\u1ea3ng l\u00e0 v\u00f4 c\u00f9ng quan tr\u1ecdng. \u0110\u00e2y ch\u00ednh l\u00e0 nh\u1eefng tr\u1ee5 c\u1ed9t t\u1ea1o n\u00ean s\u1ee9c m\u1ea1nh v\u00e0 s\u1ef1 linh ho\u1ea1t c\u1ee7a Spring.<\/span><\/p>\n<h3><b>Inversion of Control (IoC) Container<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">\u0110\u00e2y l\u00e0 nguy\u00ean t\u1eafc thi\u1ebft k\u1ebf c\u1ed1t l\u00f5i v\u00e0 c\u0169ng l\u00e0 th\u00e0nh ph\u1ea7n trung t\u00e2m c\u1ee7a Spring.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Thay v\u00ec b\u1ea1n ph\u1ea3i t\u1ef1 tay t\u1ea1o v\u00e0 qu\u1ea3n l\u00fd v\u00f2ng \u0111\u1eddi (t\u1ea1o, c\u1ea5u h\u00ecnh, li\u00ean k\u1ebft, h\u1ee7y) c\u1ee7a c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng (objects) trong \u1ee9ng d\u1ee5ng, b\u1ea1n giao ph\u00f3 tr\u00e1ch nhi\u1ec7m n\u00e0y cho m\u1ed9t th\u1ef1c th\u1ec3 b\u00ean ngo\u00e0i &#8211; ch\u00ednh l\u00e0 <\/span><b>Spring IoC Container<\/b><span style=\"font-weight: 400;\">. N\u00f3 s\u1ebd \u0111\u1ecdc th\u00f4ng tin c\u1ea5u h\u00ecnh (configuration metadata) v\u00e0 d\u1ef1a v\u00e0o \u0111\u00f3 \u0111\u1ec3 kh\u1edfi t\u1ea1o, c\u1ea5u h\u00ecnh v\u00e0 l\u1eafp r\u00e1p c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng (sau n\u00e0y g\u1ecdi l\u00e0 <\/span><b>Spring Beans<\/b><span style=\"font-weight: 400;\">). Vi\u1ec7c &#8220;\u0111\u1ea3o ng\u01b0\u1ee3c quy\u1ec1n \u0111i\u1ec1u khi\u1ec3n&#8221; (Inversion of Control) n\u00e0y gi\u00fap gi\u1ea3m s\u1ef1 ph\u1ee5 thu\u1ed9c l\u1eabn nhau gi\u1eefa c\u00e1c th\u00e0nh ph\u1ea7n trong \u1ee9ng d\u1ee5ng.<\/span><\/p>\n<p><b>C\u00e1c lo\u1ea1i Container:<\/b><span style=\"font-weight: 400;\"> Spring cung c\u1ea5p hai lo\u1ea1i IoC container ch\u00ednh:<\/span><\/p>\n<ul>\n<li><b>BeanFactory<\/b><span style=\"font-weight: 400;\">: L\u00e0 container c\u01a1 b\u1ea3n nh\u1ea5t, cung c\u1ea5p c\u00e1c ch\u1ee9c n\u0103ng c\u1ed1t l\u00f5i c\u1ee7a IoC v\u00e0 DI. N\u00f3 th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong c\u00e1c m\u00f4i tr\u01b0\u1eddng c\u00f3 t\u00e0i nguy\u00ean h\u1ea1n ch\u1ebf. BeanFactory s\u1eed d\u1ee5ng c\u01a1 ch\u1ebf kh\u1edfi t\u1ea1o l\u01b0\u1eddi (lazy initialization), t\u1ee9c l\u00e0 bean ch\u1ec9 \u0111\u01b0\u1ee3c t\u1ea1o khi \u0111\u01b0\u1ee3c y\u00eau c\u1ea7u l\u1ea7n \u0111\u1ea7u.<\/span><\/li>\n<li><b>ApplicationContext<\/b><span style=\"font-weight: 400;\">: L\u00e0 m\u1ed9t interface k\u1ebf th\u1eeba t\u1eeb <\/span><span style=\"font-weight: 400;\">BeanFactory<\/span><span style=\"font-weight: 400;\">, cung c\u1ea5p nhi\u1ec1u t\u00ednh n\u0103ng n\u00e2ng cao h\u01a1n nh\u01b0 qu\u1ea3n l\u00fd s\u1ef1 ki\u1ec7n (event publication), t\u00edch h\u1ee3p AOP, h\u1ed7 tr\u1ee3 qu\u1ed1c t\u1ebf h\u00f3a (i18n), v\u00e0 d\u1ec5 d\u00e0ng t\u00edch h\u1ee3p v\u1edbi c\u00e1c d\u1ecbch v\u1ee5 kh\u00e1c c\u1ee7a Spring. N\u00f3 th\u01b0\u1eddng kh\u1edfi t\u1ea1o c\u00e1c bean singleton ngay khi container kh\u1edfi \u0111\u1ed9ng (eager initialization). <\/span><span style=\"font-weight: 400;\">ApplicationContext<\/span><span style=\"font-weight: 400;\"> l\u00e0 lo\u1ea1i container \u0111\u01b0\u1ee3c khuy\u00ean d\u00f9ng v\u00e0 s\u1eed d\u1ee5ng ph\u1ed5 bi\u1ebfn nh\u1ea5t trong c\u00e1c \u1ee9ng d\u1ee5ng hi\u1ec7n \u0111\u1ea1i.<\/span><\/li>\n<\/ul>\n<h3><b>Dependency Injection (DI)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">DI l\u00e0 m\u1ed9t <\/span><i><span style=\"font-weight: 400;\">m\u00f4 h\u00ecnh thi\u1ebft k\u1ebf (design pattern)<\/span><\/i><span style=\"font-weight: 400;\"> c\u1ee5 th\u1ec3 \u0111\u1ec3 hi\u1ec7n th\u1ef1c h\u00f3a nguy\u00ean t\u1eafc IoC.<\/span><\/p>\n<p><b>C\u00e1ch ho\u1ea1t \u0111\u1ed9ng:<\/b><span style=\"font-weight: 400;\"> Thay v\u00ec m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng t\u1ef1 t\u00ecm ki\u1ebfm ho\u1eb7c t\u1ea1o ra c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng kh\u00e1c m\u00e0 n\u00f3 c\u1ea7n (g\u1ecdi l\u00e0 <\/span><i><span style=\"font-weight: 400;\">dependencies<\/span><\/i><span style=\"font-weight: 400;\">), IoC Container s\u1ebd ch\u1ee7 \u0111\u1ed9ng <\/span><b>&#8220;ti\u00eam&#8221; (inject)<\/b><span style=\"font-weight: 400;\"> c\u00e1c dependencies n\u00e0y v\u00e0o \u0111\u1ed1i t\u01b0\u1ee3ng khi n\u00f3 \u0111\u01b0\u1ee3c t\u1ea1o ra. N\u00f3i c\u00e1ch kh\u00e1c, c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng kh\u00f4ng t\u1ef1 lo vi\u1ec7c t\u1ea1o dependencies c\u1ee7a m\u00ecnh, m\u00e0 \u0111\u01b0\u1ee3c cung c\u1ea5p t\u1eeb b\u00ean ngo\u00e0i (b\u1edfi Container).<\/span><\/p>\n<p><b>C\u00e1c ki\u1ec3u DI ph\u1ed5 bi\u1ebfn:<\/b><\/p>\n<ul>\n<li><b>Constructor Injection:<\/b><span style=\"font-weight: 400;\"> Dependencies \u0111\u01b0\u1ee3c cung c\u1ea5p th\u00f4ng qua constructor c\u1ee7a l\u1edbp. \u0110\u00e2y l\u00e0 c\u00e1ch \u0111\u01b0\u1ee3c khuy\u1ebfn ngh\u1ecb v\u00ec n\u00f3 \u0111\u1ea3m b\u1ea3o \u0111\u1ed1i t\u01b0\u1ee3ng lu\u00f4n c\u00f3 \u0111\u1ee7 dependencies c\u1ea7n thi\u1ebft ngay khi \u0111\u01b0\u1ee3c t\u1ea1o ra v\u00e0 gi\u00fap t\u1ea1o c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng b\u1ea5t bi\u1ebfn (immutable).<\/span><\/li>\n<li><b>Setter Injection:<\/b><span style=\"font-weight: 400;\"> Dependencies \u0111\u01b0\u1ee3c ti\u00eam th\u00f4ng qua c\u00e1c ph\u01b0\u01a1ng th\u1ee9c setter c\u1ee7a l\u1edbp. C\u00e1ch n\u00e0y linh ho\u1ea1t h\u01a1n, cho ph\u00e9p thay \u0111\u1ed5i dependency sau khi \u0111\u1ed1i t\u01b0\u1ee3ng \u0111\u00e3 \u0111\u01b0\u1ee3c t\u1ea1o, nh\u01b0ng kh\u00f4ng \u0111\u1ea3m b\u1ea3o dependency lu\u00f4n t\u1ed3n t\u1ea1i.<\/span><\/li>\n<li><b>Interface Injection:<\/b><span style=\"font-weight: 400;\"> Dependencies \u0111\u01b0\u1ee3c ti\u00eam th\u00f4ng qua vi\u1ec7c c\u00e0i \u0111\u1eb7t m\u1ed9t interface \u0111\u1ecbnh ngh\u0129a ph\u01b0\u01a1ng th\u1ee9c inject. Ki\u1ec3u n\u00e0y hi\u1ec7n nay \u00edt \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong Spring.<\/span><\/li>\n<\/ul>\n<h3><b>Spring Beans<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Trong ng\u1eef c\u1ea3nh c\u1ee7a Spring, <\/span><b>Beans<\/b><span style=\"font-weight: 400;\"> l\u00e0 c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng Java th\u00f4ng th\u01b0\u1eddng (POJOs) nh\u01b0ng \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o, l\u1eafp r\u00e1p v\u00e0 qu\u1ea3n l\u00fd v\u00f2ng \u0111\u1eddi b\u1edfi Spring IoC Container. Ch\u00fang ch\u00ednh l\u00e0 c\u00e1c th\u00e0nh ph\u1ea7n c\u1ea5u t\u1ea1o n\u00ean \u1ee9ng d\u1ee5ng c\u1ee7a b\u1ea1n.<\/span><\/p>\n<p><b>Bean Scopes (Ph\u1ea1m vi c\u1ee7a Bean):<\/b><span style=\"font-weight: 400;\"> Scope \u0111\u1ecbnh ngh\u0129a v\u00f2ng \u0111\u1eddi v\u00e0 kh\u1ea3 n\u0103ng hi\u1ec3n th\u1ecb c\u1ee7a m\u1ed9t bean trong container. C\u00e1c scope ph\u1ed5 bi\u1ebfn nh\u1ea5t bao g\u1ed3m:<\/span><\/p>\n<ul>\n<li><b>Singleton (M\u1eb7c \u0111\u1ecbnh):<\/b><span style=\"font-weight: 400;\"> Ch\u1ec9 c\u00f3 <\/span><i><span style=\"font-weight: 400;\">m\u1ed9t<\/span><\/i><span style=\"font-weight: 400;\"> th\u1ec3 hi\u1ec7n (instance) duy nh\u1ea5t c\u1ee7a bean \u0111\u01b0\u1ee3c t\u1ea1o ra cho m\u1ed7i IoC container. M\u1ecdi y\u00eau c\u1ea7u \u0111\u1ebfn bean n\u00e0y \u0111\u1ec1u tr\u1ea3 v\u1ec1 c\u00f9ng m\u1ed9t th\u1ec3 hi\u1ec7n.<\/span><\/li>\n<li><b>Prototype:<\/b><span style=\"font-weight: 400;\"> M\u1ed7i khi c\u00f3 y\u00eau c\u1ea7u l\u1ea5y bean t\u1eeb container, m\u1ed9t th\u1ec3 hi\u1ec7n <\/span><i><span style=\"font-weight: 400;\">m\u1edbi<\/span><\/i><span style=\"font-weight: 400;\"> s\u1ebd \u0111\u01b0\u1ee3c t\u1ea1o ra. Container t\u1ea1o v\u00e0 c\u1ea5u h\u00ecnh bean, nh\u01b0ng kh\u00f4ng qu\u1ea3n l\u00fd to\u00e0n b\u1ed9 v\u00f2ng \u0111\u1eddi c\u1ee7a n\u00f3 sau \u0111\u00f3.<\/span><\/li>\n<li><b>Request:<\/b><span style=\"font-weight: 400;\"> (Ch\u1ec9 d\u00f9ng trong \u1ee9ng d\u1ee5ng web) M\u1ed9t th\u1ec3 hi\u1ec7n bean m\u1edbi \u0111\u01b0\u1ee3c t\u1ea1o cho m\u1ed7i HTTP request.<\/span><\/li>\n<li><b>Session:<\/b><span style=\"font-weight: 400;\"> (Ch\u1ec9 d\u00f9ng trong \u1ee9ng d\u1ee5ng web) M\u1ed9t th\u1ec3 hi\u1ec7n bean m\u1edbi \u0111\u01b0\u1ee3c t\u1ea1o cho m\u1ed7i HTTP session.<\/span><\/li>\n<li><b>Application:<\/b><span style=\"font-weight: 400;\"> (Ch\u1ec9 d\u00f9ng trong \u1ee9ng d\u1ee5ng web) M\u1ed9t th\u1ec3 hi\u1ec7n bean duy nh\u1ea5t \u0111\u01b0\u1ee3c t\u1ea1o cho to\u00e0n b\u1ed9 v\u00f2ng \u0111\u1eddi c\u1ee7a <\/span><span style=\"font-weight: 400;\">ServletContext<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li><i><span style=\"font-weight: 400;\">V\u00e0 c\u00e1c scope t\u00f9y ch\u1ec9nh kh\u00e1c.<\/span><\/i><\/li>\n<\/ul>\n<h3><b>Configuration Metadata (Si\u00eau d\u1eef li\u1ec7u c\u1ea5u h\u00ecnh)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">\u0110\u00e2y l\u00e0 c\u00e1ch b\u1ea1n &#8220;ch\u1ec9 d\u1eabn&#8221; cho Spring IoC Container bi\u1ebft c\u1ea7n t\u1ea1o nh\u1eefng bean n\u00e0o, ch\u00fang thu\u1ed9c l\u1edbp n\u00e0o, c\u00f3 nh\u1eefng dependency g\u00ec, v\u00e0 qu\u1ea3n l\u00fd ch\u00fang ra sao.<\/span><\/p>\n<p><b>C\u00e1c h\u00ecnh th\u1ee9c c\u1ea5u h\u00ecnh:<\/b><span style=\"font-weight: 400;\"> Spring r\u1ea5t linh ho\u1ea1t v\u00e0 h\u1ed7 tr\u1ee3 nhi\u1ec1u c\u00e1ch \u0111\u1ec3 cung c\u1ea5p metadata:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>XML-based configuration:<\/b><span style=\"font-weight: 400;\"> C\u00e1ch c\u1ea5u h\u00ecnh truy\u1ec1n th\u1ed1ng, s\u1eed d\u1ee5ng c\u00e1c file XML \u0111\u1ec3 \u0111\u1ecbnh ngh\u0129a beans v\u00e0 dependencies (<\/span><span style=\"font-weight: 400;\">&lt;bean&gt;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&lt;property&gt;<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">&lt;constructor-arg&gt;<\/span><span style=\"font-weight: 400;\">). D\u1ec5 \u0111\u1ecdc v\u1edbi c\u1ea5u tr\u00fac r\u00f5 r\u00e0ng nh\u01b0ng c\u00f3 th\u1ec3 tr\u1edf n\u00ean d\u00e0i d\u00f2ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Annotation-based configuration:<\/b><span style=\"font-weight: 400;\"> S\u1eed d\u1ee5ng c\u00e1c annotation tr\u1ef1c ti\u1ebfp trong m\u00e3 ngu\u1ed3n Java \u0111\u1ec3 \u0111\u00e1nh d\u1ea5u c\u00e1c l\u1edbp l\u00e0 bean (<\/span><span style=\"font-weight: 400;\">@Component<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">@Service<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">@Repository<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">@Controller<\/span><span style=\"font-weight: 400;\">), \u0111\u00e1nh d\u1ea5u dependencies c\u1ea7n ti\u00eam (<\/span><span style=\"font-weight: 400;\">@Autowired<\/span><span style=\"font-weight: 400;\">), v\u00e0 c\u1ea5u h\u00ecnh kh\u00e1c (<\/span><span style=\"font-weight: 400;\">@Scope<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">@Qualifier<\/span><span style=\"font-weight: 400;\">&#8230;). C\u00e1ch n\u00e0y g\u1ecdn g\u00e0ng v\u00e0 g\u1ea7n g\u0169i v\u1edbi code h\u01a1n.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Java-based configuration (JavaConfig):<\/b><span style=\"font-weight: 400;\"> S\u1eed d\u1ee5ng c\u00e1c l\u1edbp Java v\u00e0 annotation (<\/span><span style=\"font-weight: 400;\">@Configuration<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">@Bean<\/span><span style=\"font-weight: 400;\">) \u0111\u1ec3 \u0111\u1ecbnh ngh\u0129a c\u1ea5u h\u00ecnh. C\u00e1ch n\u00e0y cung c\u1ea5p s\u1ef1 an to\u00e0n ki\u1ec3u (type safety) v\u00e0 kh\u1ea3 n\u0103ng t\u00e1i c\u1ea5u tr\u00fac t\u1ed1t h\u01a1n so v\u1edbi XML, v\u00e0 \u0111ang ng\u00e0y c\u00e0ng tr\u1edf n\u00ean ph\u1ed5 bi\u1ebfn, \u0111\u1eb7c bi\u1ec7t v\u1edbi Spring Boot.<\/span><\/li>\n<\/ul>\n<blockquote><p><i><span style=\"font-weight: 400;\">L\u01b0u \u00fd:<\/span><\/i><span style=\"font-weight: 400;\"> B\u1ea1n ho\u00e0n to\u00e0n c\u00f3 th\u1ec3 k\u1ebft h\u1ee3p c\u00e1c h\u00ecnh th\u1ee9c c\u1ea5u h\u00ecnh n\u00e0y trong c\u00f9ng m\u1ed9t d\u1ef1 \u00e1n.<\/span><\/p><\/blockquote>\n<h3><b>Aspect-Oriented Programming (AOP)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">AOP l\u00e0 m\u1ed9t m\u00f4 h\u00ecnh l\u1eadp tr\u00ecnh b\u1ed5 sung cho L\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (OOP), gi\u00fap gi\u1ea3i quy\u1ebft c\u00e1c m\u1ed1i quan t\u00e2m xuy\u00ean su\u1ed1t (cross-cutting concerns). \u0110\u00e2y l\u00e0 nh\u1eefng ch\u1ee9c n\u0103ng c\u1ea7n \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng cho nhi\u1ec1u ph\u1ea7n kh\u00e1c nhau trong \u1ee9ng d\u1ee5ng nh\u01b0ng kh\u00f4ng thu\u1ed9c v\u1ec1 logic nghi\u1ec7p v\u1ee5 c\u1ed1t l\u00f5i c\u1ee7a c\u00e1c ph\u1ea7n \u0111\u00f3 (v\u00ed d\u1ee5: logging, security, transaction management, caching).<\/span><\/p>\n<p><b>M\u1ee5c ti\u00eau:<\/b><span style=\"font-weight: 400;\"> AOP cho ph\u00e9p b\u1ea1n t\u00e1ch bi\u1ec7t c\u00e1c cross-cutting concerns n\u00e0y ra kh\u1ecfi logic nghi\u1ec7p v\u1ee5 ch\u00ednh, gi\u00fap m\u00e3 ngu\u1ed3n s\u1ea1ch s\u1ebd, d\u1ec5 b\u1ea3o tr\u00ec v\u00e0 module h\u00f3a h\u01a1n.<\/span><\/p>\n<p><b>C\u00e1c thu\u1eadt ng\u1eef ch\u00ednh trong AOP:<\/b><\/p>\n<ul>\n<li><b>Aspect:<\/b><span style=\"font-weight: 400;\"> Module ch\u1ee9a code th\u1ef1c thi cho m\u1ed9t cross-cutting concern (v\u00ed d\u1ee5: m\u1ed9t l\u1edbp \u0111\u01b0\u1ee3c \u0111\u00e1nh d\u1ea5u <\/span><span style=\"font-weight: 400;\">@Aspect<\/span><span style=\"font-weight: 400;\">). N\u00f3 bao g\u1ed3m c\u00e1c Advice v\u00e0 Pointcut.<\/span><\/li>\n<li><b>Join Point:<\/b><span style=\"font-weight: 400;\"> M\u1ed9t \u0111i\u1ec3m c\u1ee5 th\u1ec3 trong qu\u00e1 tr\u00ecnh th\u1ef1c thi ch\u01b0\u01a1ng tr\u00ecnh n\u01a1i m\u1ed9t Aspect c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c &#8220;c\u1eafm&#8221; v\u00e0o, v\u00ed d\u1ee5 nh\u01b0 vi\u1ec7c g\u1ecdi m\u1ed9t ph\u01b0\u01a1ng th\u1ee9c, x\u1eed l\u00fd m\u1ed9t ngo\u1ea1i l\u1ec7. Trong Spring AOP, join point <\/span><i><span style=\"font-weight: 400;\">lu\u00f4n l\u00e0 vi\u1ec7c th\u1ef1c thi m\u1ed9t ph\u01b0\u01a1ng th\u1ee9c<\/span><\/i><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li><b>Advice:<\/b><span style=\"font-weight: 400;\"> H\u00e0nh \u0111\u1ed9ng c\u1ee5 th\u1ec3 m\u00e0 Aspect s\u1ebd th\u1ef1c hi\u1ec7n t\u1ea1i m\u1ed9t Join Point. C\u00f3 c\u00e1c lo\u1ea1i Advice ch\u00ednh:<\/span>\n<ul>\n<li><span style=\"font-weight: 400;\">Before<\/span><span style=\"font-weight: 400;\">: Th\u1ef1c thi <\/span><i><span style=\"font-weight: 400;\">tr\u01b0\u1edbc<\/span><\/i><span style=\"font-weight: 400;\"> khi Join Point di\u1ec5n ra.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">After Returning<\/span><span style=\"font-weight: 400;\">: Th\u1ef1c thi <\/span><i><span style=\"font-weight: 400;\">sau khi<\/span><\/i><span style=\"font-weight: 400;\"> Join Point ho\u00e0n th\u00e0nh b\u00ecnh th\u01b0\u1eddng (tr\u1ea3 v\u1ec1 k\u1ebft qu\u1ea3).<\/span><\/li>\n<li><span style=\"font-weight: 400;\">After Throwing<\/span><span style=\"font-weight: 400;\">: Th\u1ef1c thi <\/span><i><span style=\"font-weight: 400;\">sau khi<\/span><\/i><span style=\"font-weight: 400;\"> Join Point k\u1ebft th\u00fac b\u1eb1ng c\u00e1ch n\u00e9m ra m\u1ed9t ngo\u1ea1i l\u1ec7.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">After (Finally)<\/span><span style=\"font-weight: 400;\">: Th\u1ef1c thi <\/span><i><span style=\"font-weight: 400;\">sau khi<\/span><\/i><span style=\"font-weight: 400;\"> Join Point k\u1ebft th\u00fac, b\u1ea5t k\u1ec3 k\u1ebft th\u00fac b\u00ecnh th\u01b0\u1eddng hay c\u00f3 l\u1ed7i.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Around<\/span><span style=\"font-weight: 400;\">: Bao b\u1ecdc xung quanh Join Point. \u0110\u00e2y l\u00e0 lo\u1ea1i Advice m\u1ea1nh m\u1ebd nh\u1ea5t, cho ph\u00e9p b\u1ea1n th\u1ef1c thi logic <\/span><i><span style=\"font-weight: 400;\">tr\u01b0\u1edbc v\u00e0 sau<\/span><\/i><span style=\"font-weight: 400;\"> Join Point, th\u1eadm ch\u00ed c\u00f3 th\u1ec3 quy\u1ebft \u0111\u1ecbnh kh\u00f4ng th\u1ef1c thi Join Point.<\/span><\/li>\n<\/ul>\n<\/li>\n<li><b>Pointcut:<\/b><span style=\"font-weight: 400;\"> M\u1ed9t bi\u1ec3u th\u1ee9c (expression) \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh <\/span><i><span style=\"font-weight: 400;\">t\u1eadp h\u1ee3p c\u00e1c Join Point<\/span><\/i><span style=\"font-weight: 400;\"> m\u00e0 m\u1ed9t Advice s\u1ebd \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng. N\u00f3 gi\u1ed1ng nh\u01b0 m\u1ed9t b\u1ed9 l\u1ecdc \u0111\u1ec3 ch\u1ecdn ra nh\u1eefng ph\u01b0\u01a1ng th\u1ee9c c\u1ea7n can thi\u1ec7p.<\/span><\/li>\n<li><b>Target Object:<\/b><span style=\"font-weight: 400;\"> \u0110\u1ed1i t\u01b0\u1ee3ng ch\u1ee9a c\u00e1c Join Point m\u00e0 Advice s\u1ebd \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng.<\/span><\/li>\n<li><b>Weaving:<\/b><span style=\"font-weight: 400;\"> Qu\u00e1 tr\u00ecnh li\u00ean k\u1ebft c\u00e1c Aspect v\u1edbi Target Object \u0111\u1ec3 t\u1ea1o ra \u0111\u1ed1i t\u01b0\u1ee3ng \u0111\u01b0\u1ee3c t\u01b0 v\u1ea5n (advised object) cu\u1ed1i c\u00f9ng. Weaving c\u00f3 th\u1ec3 x\u1ea3y ra t\u1ea1i th\u1eddi \u0111i\u1ec3m bi\u00ean d\u1ecbch (compile time), th\u1eddi \u0111i\u1ec3m n\u1ea1p l\u1edbp (load time), ho\u1eb7c th\u1eddi \u0111i\u1ec3m ch\u1ea1y (runtime). <\/span><b>Spring AOP th\u1ef1c hi\u1ec7n weaving t\u1ea1i th\u1eddi \u0111i\u1ec3m ch\u1ea1y (runtime) b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng Proxy.<\/b><\/li>\n<\/ul>\n<p><b>C\u00e1ch Spring AOP ho\u1ea1t \u0111\u1ed9ng:<\/b><span style=\"font-weight: 400;\"> Spring AOP th\u01b0\u1eddng s\u1eed d\u1ee5ng <\/span><b>JDK dynamic proxies<\/b><span style=\"font-weight: 400;\"> (n\u1ebfu target object c\u00e0i \u0111\u1eb7t interface) ho\u1eb7c <\/span><b>CGLIB proxies<\/b><span style=\"font-weight: 400;\"> (n\u1ebfu target object kh\u00f4ng c\u00e0i \u0111\u1eb7t interface) \u0111\u1ec3 t\u1ea1o ra m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng proxy bao b\u1ecdc l\u1ea5y Target Object. Khi m\u1ed9t ph\u01b0\u01a1ng th\u1ee9c tr\u00ean proxy \u0111\u01b0\u1ee3c g\u1ecdi, proxy s\u1ebd quy\u1ebft \u0111\u1ecbnh xem c\u00f3 c\u1ea7n th\u1ef1c thi c\u00e1c Advice li\u00ean quan (d\u1ef1a tr\u00ean Pointcut) tr\u01b0\u1edbc\/sau\/xung quanh vi\u1ec7c g\u1ecdi ph\u01b0\u01a1ng th\u1ee9c th\u1ef1c s\u1ef1 tr\u00ean Target Object hay kh\u00f4ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Vi\u1ec7c hi\u1ec3u r\u00f5 c\u00e1c kh\u00e1i ni\u1ec7m n\u00e0y s\u1ebd gi\u00fap b\u1ea1n khai th\u00e1c t\u1ed1i \u0111a s\u1ee9c m\u1ea1nh c\u1ee7a Spring Framework trong vi\u1ec7c x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng Java hi\u1ec7u qu\u1ea3 v\u00e0 ch\u1ea5t l\u01b0\u1ee3ng cao.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Kien_truc_va_cac_module_chinh\"><\/span><b>Ki\u1ebfn tr\u00fac v\u00e0 c\u00e1c module ch\u00ednh<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Spring Framework \u0111\u01b0\u1ee3c thi\u1ebft k\u1ebf theo ki\u1ebfn tr\u00fac module h\u00f3a r\u1ea5t cao. \u0110i\u1ec1u n\u00e0y c\u00f3 ngh\u0129a l\u00e0 b\u1ea1n kh\u00f4ng c\u1ea7n ph\u1ea3i s\u1eed d\u1ee5ng to\u00e0n b\u1ed9 framework m\u00e0 ch\u1ec9 c\u1ea7n ch\u1ecdn l\u1ef1a nh\u1eefng ph\u1ea7n (module) ph\u00f9 h\u1ee3p v\u1edbi nhu c\u1ea7u c\u1ee5 th\u1ec3 c\u1ee7a \u1ee9ng d\u1ee5ng. C\u00e1c module n\u00e0y \u0111\u01b0\u1ee3c t\u1ed5 ch\u1ee9c th\u00e0nh c\u00e1c nh\u00f3m ch\u1ee9c n\u0103ng ch\u00ednh:<\/span><\/p>\n<h3><b>S\u01a1 \u0111\u1ed3 ki\u1ebfn tr\u00fac t\u1ed5ng quan<\/b><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-61308\" src=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/02\/spring-framework-vippro.png\" alt=\"ki\u1ebfn tr\u00fac spring framework\" width=\"2688\" height=\"1827\" srcset=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/02\/spring-framework-vippro.png 2688w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/02\/spring-framework-vippro-300x204.png 300w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/02\/spring-framework-vippro-1600x1088.png 640w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/02\/spring-framework-vippro-200x136.png 200w, https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/02\/spring-framework-vippro-100x68.png 100w\" sizes=\"auto, (max-width: 2688px) 100vw, 2688px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">S\u01a1 \u0111\u1ed3 n\u00e0y bi\u1ec3u di\u1ec5n tr\u1ef1c quan v\u1ec1 ki\u1ebfn tr\u00fac module c\u1ee7a Spring Framework, cho th\u1ea5y c\u00e1ch Spring \u0111\u01b0\u1ee3c chia th\u00e0nh c\u00e1c nh\u00f3m ch\u1ee9c n\u0103ng ri\u00eang bi\u1ec7t, cho ph\u00e9p b\u1ea1n ch\u1ec9 s\u1eed d\u1ee5ng nh\u1eefng ph\u1ea7n c\u1ea7n thi\u1ebft, s\u01a1 \u0111\u1ed3 n\u00e0y minh h\u1ecda r\u1eb1ng Spring kh\u00f4ng ph\u1ea3i l\u00e0 m\u1ed9t kh\u1ed1i monolithic kh\u1ed5ng l\u1ed3. N\u00f3 \u0111\u01b0\u1ee3c c\u1ea5u t\u1ea1o t\u1eeb nhi\u1ec1u module \u0111\u1ed9c l\u1eadp nh\u01b0ng li\u00ean k\u1ebft ch\u1eb7t ch\u1ebd, v\u1edbi Core Container l\u00e0 trung t\u00e2m, v\u00e0 c\u00e1c module kh\u00e1c cung c\u1ea5p ch\u1ee9c n\u0103ng chuy\u00ean bi\u1ec7t cho t\u1eebng l\u0129nh v\u1ef1c nh\u01b0 truy c\u1eadp d\u1eef li\u1ec7u, ph\u00e1t tri\u1ec3n web, AOP, v\u00e0 ki\u1ec3m th\u1eed.<\/span><\/p>\n<h3><b>C\u00e1c container c\u1ed1t l\u00f5i (Core Container)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">\u0110\u00e2y l\u00e0 n\u1ec1n t\u1ea3ng c\u01a1 b\u1ea3n nh\u1ea5t c\u1ee7a Spring Framework, cung c\u1ea5p c\u00e1c ch\u1ee9c n\u0103ng c\u1ed1t l\u00f5i nh\u01b0 IoC (Inversion of Control) v\u00e0 DI (Dependency Injection). N\u00f3 bao g\u1ed3m c\u00e1c module ch\u00ednh sau:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-core<\/b><span style=\"font-weight: 400;\">: Cung c\u1ea5p c\u00e1c l\u1edbp ti\u1ec7n \u00edch c\u01a1 b\u1ea3n \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng xuy\u00ean su\u1ed1t framework, v\u00e0 quan tr\u1ecdng nh\u1ea5t l\u00e0 ch\u1ee9a \u0111\u1ef1ng c\u00e1c kh\u00e1i ni\u1ec7m n\u1ec1n t\u1ea3ng c\u1ee7a <\/span><b>Inversion of Control (IoC)<\/b><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-beans<\/b><span style=\"font-weight: 400;\">: Cung c\u1ea5p <\/span><span style=\"font-weight: 400;\">BeanFactory<\/span><span style=\"font-weight: 400;\">, m\u1ed9t d\u1ea1ng tri\u1ec3n khai tinh vi c\u1ee7a m\u1eabu thi\u1ebft k\u1ebf Factory. Module n\u00e0y ch\u1ecbu tr\u00e1ch nhi\u1ec7m <\/span><b>qu\u1ea3n l\u00fd vi\u1ec7c t\u1ea1o, c\u1ea5u h\u00ecnh v\u00e0 v\u00f2ng \u0111\u1eddi c\u1ee7a c\u00e1c Spring Beans<\/b><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-context<\/b><span style=\"font-weight: 400;\">: X\u00e2y d\u1ef1ng d\u1ef1a tr\u00ean <\/span><span style=\"font-weight: 400;\">spring-core<\/span><span style=\"font-weight: 400;\"> v\u00e0 <\/span><span style=\"font-weight: 400;\">spring-beans<\/span><span style=\"font-weight: 400;\">, module n\u00e0y cung c\u1ea5p <\/span><span style=\"font-weight: 400;\">ApplicationContext<\/span><span style=\"font-weight: 400;\"> &#8211; m\u1ed9t interface m\u1ea1nh m\u1ebd h\u01a1n <\/span><span style=\"font-weight: 400;\">BeanFactory<\/span><span style=\"font-weight: 400;\">. N\u00f3 b\u1ed5 sun<\/span><b>g c\u00e1c t\u00ednh n\u0103ng nh\u01b0 h\u1ed7 tr\u1ee3 qu\u1ed1c t\u1ebf h\u00f3a (internationalization &#8211; i18n), c\u01a1 ch\u1ebf x\u1eed l\u00fd s\u1ef1 ki\u1ec7n (event propagation), n\u1ea1p t\u00e0i nguy\u00ean (resource loading), v\u00e0 t\u00edch h\u1ee3p d\u1ec5 d\u00e0ng v\u1edbi c\u00e1c t\u00ednh n\u0103ng kh\u00e1c <\/b><span style=\"font-weight: 400;\">c\u1ee7a Spring nh\u01b0 AOP, Transaction Management.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-expression<\/b><span style=\"font-weight: 400;\"> (SpEL &#8211; Spring Expression Language): Cung c\u1ea5p m\u1ed9t <\/span><b>ng\u00f4n ng\u1eef bi\u1ec3u th\u1ee9c m\u1ea1nh m\u1ebd<\/b><span style=\"font-weight: 400;\"> cho ph\u00e9p truy v\u1ea5n v\u00e0 thao t\u00e1c v\u1edbi c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng (object graph) t\u1ea1i th\u1eddi \u0111i\u1ec3m ch\u1ea1y. N\u00f3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong nhi\u1ec1u module kh\u00e1c c\u1ee7a Spring, \u0111\u1eb7c bi\u1ec7t l\u00e0 trong vi\u1ec7c \u0111\u1ecbnh ngh\u0129a bean v\u00e0 c\u00e1c quy t\u1eafc b\u1ea3o m\u1eadt.<\/span><\/li>\n<\/ul>\n<h3><b>Data Access\/Integration (Truy c\u1eadp d\u1eef li\u1ec7u\/T\u00edch h\u1ee3p)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Nh\u00f3m n\u00e0y bao g\u1ed3m c\u00e1c module gi\u00fap \u0111\u01a1n gi\u1ea3n h\u00f3a vi\u1ec7c t\u01b0\u01a1ng t\u00e1c v\u1edbi c\u00e1c ngu\u1ed3n d\u1eef li\u1ec7u v\u00e0 t\u00edch h\u1ee3p v\u1edbi c\u00e1c c\u00f4ng ngh\u1ec7 truy c\u1eadp d\u1eef li\u1ec7u kh\u00e1c:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-jdbc<\/b><span style=\"font-weight: 400;\">: Cung c\u1ea5p m\u1ed9t l\u1edbp tr\u1eebu t\u01b0\u1ee3ng h\u00f3a tr\u00ean n\u1ec1n JDBC, gi\u00fap <\/span><b>\u0111\u01a1n gi\u1ea3n h\u00f3a vi\u1ec7c truy c\u1eadp c\u01a1 s\u1edf d\u1eef li\u1ec7u quan h\u1ec7 th\u00f4ng qua JDBC<\/b><span style=\"font-weight: 400;\">. N\u00f3 lo\u1ea1i b\u1ecf r\u1ea5t nhi\u1ec1u m\u00e3 l\u1eb7p (boilerplate code) li\u00ean quan \u0111\u1ebfn vi\u1ec7c m\u1edf\/\u0111\u00f3ng k\u1ebft n\u1ed1i, x\u1eed l\u00fd <\/span><span style=\"font-weight: 400;\">SQLException<\/span><span style=\"font-weight: 400;\">, v\u00e0 qu\u1ea3n l\u00fd t\u00e0i nguy\u00ean.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-orm<\/b><span style=\"font-weight: 400;\"> (Object-Relational Mapping): Cung c\u1ea5p c\u00e1c l\u1edbp t\u00edch h\u1ee3p \u0111\u1ec3 <\/span><b>s\u1eed d\u1ee5ng c\u00e1c framework ORM ph\u1ed5 bi\u1ebfn<\/b><span style=\"font-weight: 400;\"> nh\u01b0 Hibernate, JPA (Java Persistence API), JDO m\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng h\u01a1n trong m\u00f4i tr\u01b0\u1eddng Spring. N\u00f3 gi\u00fap qu\u1ea3n l\u00fd <\/span><span style=\"font-weight: 400;\">SessionFactory<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">EntityManagerFactory<\/span><span style=\"font-weight: 400;\"> v\u00e0 t\u00edch h\u1ee3p v\u1edbi qu\u1ea3n l\u00fd giao d\u1ecbch c\u1ee7a Spring.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-tx<\/b><span style=\"font-weight: 400;\"> (Transaction Management): Cung c\u1ea5p c\u01a1 ch\u1ebf <\/span><b>qu\u1ea3n l\u00fd giao d\u1ecbch (transaction) m\u1ed9t c\u00e1ch nh\u1ea5t qu\u00e1n<\/b><span style=\"font-weight: 400;\"> cho nhi\u1ec1u lo\u1ea1i API kh\u00e1c nhau (JDBC, JPA, Hibernate, JTA&#8230;). N\u00f3 h\u1ed7 tr\u1ee3 c\u1ea3 qu\u1ea3n l\u00fd giao d\u1ecbch khai b\u00e1o (declarative transaction management &#8211; th\u00f4ng qua annotation ho\u1eb7c XML) v\u00e0 qu\u1ea3n l\u00fd giao d\u1ecbch l\u1eadp tr\u00ecnh (programmatic transaction management).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-jms<\/b><span style=\"font-weight: 400;\"> (Java Message Service): Ch\u1ee9a c\u00e1c t\u00ednh n\u0103ng \u0111\u1ec3 s\u1ea3n xu\u1ea5t (producing) v\u00e0 ti\u00eau th\u1ee5 (consuming) c\u00e1c tin nh\u1eafn JMS, \u0111\u01a1n gi\u1ea3n h\u00f3a vi\u1ec7c l\u00e0m vi\u1ec7c v\u1edbi c\u00e1c h\u1ec7 th\u1ed1ng message queue.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-oxm<\/b><span style=\"font-weight: 400;\"> (Object\/XML Mapping): Cung c\u1ea5p l\u1edbp tr\u1eebu t\u01b0\u1ee3ng h\u00f3a \u0111\u1ec3 h\u1ed7 tr\u1ee3 vi\u1ec7c \u00e1nh x\u1ea1 gi\u1eefa \u0111\u1ed1i t\u01b0\u1ee3ng Java v\u00e0 t\u00e0i li\u1ec7u XML, t\u00edch h\u1ee3p v\u1edbi c\u00e1c th\u01b0 vi\u1ec7n nh\u01b0 JAXB, Castor, XMLBeans\u2026<\/span><\/li>\n<\/ul>\n<h3><b>Web<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Nh\u00f3m module n\u00e0y cung c\u1ea5p n\u1ec1n t\u1ea3ng \u0111\u1ec3 x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng web, bao g\u1ed3m c\u1ea3 c\u00e1c \u1ee9ng d\u1ee5ng d\u1ef1a tr\u00ean Servlet truy\u1ec1n th\u1ed1ng v\u00e0 c\u00e1c \u1ee9ng d\u1ee5ng ph\u1ea3n \u1ee9ng (reactive):<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-web<\/b><span style=\"font-weight: 400;\">: Cung c\u1ea5p c\u00e1c <\/span><b>t\u00ednh n\u0103ng web c\u01a1 b\u1ea3n<\/b><span style=\"font-weight: 400;\"> nh\u01b0 ch\u1ee9c n\u0103ng upload file multipart, kh\u1edfi t\u1ea1o IoC container s\u1eed d\u1ee5ng servlet listeners (<\/span><span style=\"font-weight: 400;\">WebApplicationContext<\/span><span style=\"font-weight: 400;\">), v\u00e0 m\u1ed9t HTTP client ph\u00eda client (<\/span><span style=\"font-weight: 400;\">RestTemplate<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">WebClient<\/span><span style=\"font-weight: 400;\">).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-webmvc<\/b><b> (c\u00f2n g\u1ecdi l\u00e0 Spring MVC)<\/b><span style=\"font-weight: 400;\">: Ch\u1ee9a \u0111\u1ef1ng vi\u1ec7c tri\u1ec3n khai <\/span><b>framework Model-View-Controller (MVC)<\/b><span style=\"font-weight: 400;\"> c\u1ee7a Spring cho c\u00e1c \u1ee9ng d\u1ee5ng web. N\u00f3 t\u00e1ch bi\u1ec7t r\u00f5 r\u00e0ng gi\u1eefa logic x\u1eed l\u00fd request, logic nghi\u1ec7p v\u1ee5, v\u00e0 ph\u1ea7n hi\u1ec3n th\u1ecb giao di\u1ec7n, gi\u00fap x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng web c\u00f3 c\u1ea5u tr\u00fac t\u1ed1t v\u00e0 d\u1ec5 b\u1ea3o tr\u00ec.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-websocket<\/b><span style=\"font-weight: 400;\">: Cung c\u1ea5p h\u1ed7 tr\u1ee3 cho vi\u1ec7c x\u00e2y d\u1ef1ng giao ti\u1ebfp hai chi\u1ec1u d\u1ef1a tr\u00ean <\/span><b>WebSocket<\/b><span style=\"font-weight: 400;\"> trong c\u00e1c \u1ee9ng d\u1ee5ng web.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>spring-webflux<\/b><span style=\"font-weight: 400;\">: \u0110\u01b0\u1ee3c gi\u1edbi thi\u1ec7u trong Spring 5, module n\u00e0y cung c\u1ea5p m\u1ed9t <\/span><b>framework web ph\u1ea3n \u1ee9ng (reactive), non-blocking<\/b><span style=\"font-weight: 400;\"> \u0111\u1ec3 x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng c\u00f3 kh\u1ea3 n\u0103ng m\u1edf r\u1ed9ng v\u00e0 ch\u1ecbu t\u1ea3i cao, d\u1ef1a tr\u00ean c\u00e1c th\u01b0 vi\u1ec7n nh\u01b0 Project Reactor.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Ki\u1ebfn tr\u00fac module linh ho\u1ea1t n\u00e0y cho ph\u00e9p c\u00e1c nh\u00e0 ph\u00e1t tri\u1ec3n l\u1ef1a ch\u1ecdn ch\u00ednh x\u00e1c nh\u1eefng g\u00ec h\u1ecd c\u1ea7n, l\u00e0m cho Spring tr\u1edf th\u00e0nh m\u1ed9t n\u1ec1n t\u1ea3ng m\u1ea1nh m\u1ebd v\u00e0 th\u00edch \u1ee9ng t\u1ed1t v\u1edbi nhi\u1ec1u lo\u1ea1i d\u1ef1 \u00e1n kh\u00e1c nhau.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"He_sinh_thai_Spring_gom_nhung_thanh_phan_nao\"><\/span><b>H\u1ec7 sinh th\u00e1i Spring g\u1ed3m nh\u1eefng th\u00e0nh ph\u1ea7n n\u00e0o?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Ngo\u00e0i Spring Framework c\u1ed1t l\u00f5i, s\u1ee9c m\u1ea1nh th\u1ef1c s\u1ef1 c\u1ee7a Spring c\u00f2n n\u1eb1m \u1edf m\u1ed9t h\u1ec7 sinh th\u00e1i c\u00e1c d\u1ef1 \u00e1n (projects) phong ph\u00fa xung quanh n\u00f3. C\u00e1c d\u1ef1 \u00e1n n\u00e0y \u0111\u01b0\u1ee3c x\u00e2y d\u1ef1ng d\u1ef1a tr\u00ean n\u1ec1n t\u1ea3ng Spring Core, m\u1edf r\u1ed9ng kh\u1ea3 n\u0103ng v\u00e0 gi\u1ea3i quy\u1ebft c\u00e1c v\u1ea5n \u0111\u1ec1 c\u1ee5 th\u1ec3 trong ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng hi\u1ec7n \u0111\u1ea1i. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 nh\u1eefng th\u00e0nh ph\u1ea7n n\u1ed5i b\u1eadt nh\u1ea5t:<\/span><\/p>\n<h3><b>Spring Boot<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">\u0110\u00e2y c\u00f3 l\u1ebd l\u00e0 d\u1ef1 \u00e1n <\/span><b>quan tr\u1ecdng v\u00e0 ph\u1ed5 bi\u1ebfn nh\u1ea5t<\/b><span style=\"font-weight: 400;\"> trong h\u1ec7 sinh th\u00e1i Spring hi\u1ec7n nay, \u0111\u00f3ng vai tr\u00f2 c\u00e1ch m\u1ea1ng h\u00f3a c\u00e1ch ch\u00fang ta x\u00e2y d\u1ef1ng v\u00e0 tri\u1ec3n khai \u1ee9ng d\u1ee5ng Spring.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Spring Boot gi\u00fap t\u1ea1o v\u00e0 ch\u1ea1y c\u00e1c \u1ee9ng d\u1ee5ng Spring \u0111\u1ed9c l\u1eadp (stand-alone), s\u1eb5n s\u00e0ng cho m\u00f4i tr\u01b0\u1eddng production m\u1ed9t c\u00e1ch c\u1ef1c k\u1ef3 nhanh ch\u00f3ng v\u00e0 \u0111\u01a1n gi\u1ea3n, th\u01b0\u1eddng ch\u1ec9 v\u1edbi m\u1ed9t v\u00e0i d\u00f2ng c\u1ea5u h\u00ecnh ho\u1eb7c th\u1eadm ch\u00ed kh\u00f4ng c\u1ea7n c\u1ea5u h\u00ecnh g\u00ec c\u1ea3 (&#8220;Just Run&#8221;). N\u00f3 lo\u1ea1i b\u1ecf ph\u1ea7n l\u1edbn g\u00e1nh n\u1eb7ng c\u1ea5u h\u00ecnh ban \u0111\u1ea7u th\u01b0\u1eddng th\u1ea5y \u1edf c\u00e1c d\u1ef1 \u00e1n Spring truy\u1ec1n th\u1ed1ng.<\/span><\/p>\n<p><b>\u0110\u1eb7c \u0111i\u1ec3m n\u1ed5i b\u1eadt:<\/b><\/p>\n<ul>\n<li><b>Auto-configuration (T\u1ef1 \u0111\u1ed9ng c\u1ea5u h\u00ecnh):<\/b><span style=\"font-weight: 400;\"> Spring Boot t\u1ef1 \u0111\u1ed9ng c\u1ea5u h\u00ecnh \u1ee9ng d\u1ee5ng c\u1ee7a b\u1ea1n d\u1ef1a tr\u00ean c\u00e1c th\u01b0 vi\u1ec7n (dependencies) m\u00e0 b\u1ea1n \u0111\u00e3 th\u00eam v\u00e0o. V\u00ed d\u1ee5, n\u1ebfu ph\u00e1t hi\u1ec7n c\u00f3 <\/span><span style=\"font-weight: 400;\">spring-webmvc<\/span><span style=\"font-weight: 400;\"> trong classpath, n\u00f3 s\u1ebd t\u1ef1 \u0111\u1ed9ng c\u1ea5u h\u00ecnh DispatcherServlet v\u00e0 c\u00e1c th\u00e0nh ph\u1ea7n web c\u1ea7n thi\u1ebft kh\u00e1c.<\/span><\/li>\n<li><b>Opinionated Defaults (C\u1ea5u h\u00ecnh m\u1eb7c \u0111\u1ecbnh c\u00f3 ch\u1ee7 \u0111\u00edch):<\/b><span style=\"font-weight: 400;\"> Spring Boot \u0111\u01b0a ra c\u00e1c l\u1ef1a ch\u1ecdn c\u1ea5u h\u00ecnh m\u1eb7c \u0111\u1ecbnh h\u1ee3p l\u00fd cho h\u1ea7u h\u1ebft c\u00e1c t\u00ecnh hu\u1ed1ng ph\u1ed5 bi\u1ebfn, gi\u00fap b\u1ea1n b\u1eaft \u0111\u1ea7u nhanh ch\u00f3ng m\u00e0 kh\u00f4ng c\u1ea7n quy\u1ebft \u0111\u1ecbnh qu\u00e1 nhi\u1ec1u. Tuy nhi\u00ean, b\u1ea1n ho\u00e0n to\u00e0n c\u00f3 th\u1ec3 ghi \u0111\u00e8 c\u00e1c c\u1ea5u h\u00ecnh m\u1eb7c \u0111\u1ecbnh n\u00e0y n\u1ebfu c\u1ea7n.<\/span><\/li>\n<li><b>Embedded Servers (M\u00e1y ch\u1ee7 nh\u00fang):<\/b><span style=\"font-weight: 400;\"> Cho ph\u00e9p \u0111\u00f3ng g\u00f3i \u1ee9ng d\u1ee5ng c\u00f9ng v\u1edbi m\u1ed9t m\u00e1y ch\u1ee7 web nh\u00fang (nh\u01b0 Tomcat, Jetty, ho\u1eb7c Undertow) th\u00e0nh m\u1ed9t file JAR ho\u1eb7c WAR duy nh\u1ea5t c\u00f3 th\u1ec3 ch\u1ea1y \u0111\u1ed9c l\u1eadp, kh\u00f4ng c\u1ea7n tri\u1ec3n khai l\u00ean m\u1ed9t application server ri\u00eang bi\u1ec7t.<\/span><\/li>\n<li><b>Production-ready Features (T\u00ednh n\u0103ng s\u1eb5n s\u00e0ng cho Production):<\/b><span style=\"font-weight: 400;\"> T\u00edch h\u1ee3p s\u1eb5n c\u00e1c t\u00ednh n\u0103ng c\u1ea7n thi\u1ebft cho m\u00f4i tr\u01b0\u1eddng v\u1eadn h\u00e0nh nh\u01b0 <\/span><b>metrics<\/b><span style=\"font-weight: 400;\"> (thu th\u1eadp s\u1ed1 li\u1ec7u ho\u1ea1t \u0111\u1ed9ng), <\/span><b>health checks<\/b><span style=\"font-weight: 400;\"> (ki\u1ec3m tra t\u00ecnh tr\u1ea1ng \u1ee9ng d\u1ee5ng), v\u00e0 externalized configuration (qu\u1ea3n l\u00fd c\u1ea5u h\u00ecnh b\u00ean ngo\u00e0i \u1ee9ng d\u1ee5ng).<\/span><\/li>\n<\/ul>\n<p><b>T\u1ea7m quan tr\u1ecdng:<\/b><span style=\"font-weight: 400;\"> Spring Boot \u0111\u00e3 tr\u1edf th\u00e0nh c\u00e1ch ti\u1ebfp c\u1eadn ti\u00eau chu\u1ea9n v\u00e0 ph\u1ed5 bi\u1ebfn nh\u1ea5t \u0111\u1ec3 b\u1eaft \u0111\u1ea7u m\u1ed9t d\u1ef1 \u00e1n Spring m\u1edbi nh\u1edd s\u1ef1 \u0111\u01a1n gi\u1ea3n, t\u1ed1c \u0111\u1ed9 ph\u00e1t tri\u1ec3n nhanh v\u00e0 kh\u1ea3 n\u0103ng tri\u1ec3n khai d\u1ec5 d\u00e0ng.<\/span><\/p>\n<h3><b>Spring Data<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">D\u1ef1 \u00e1n n\u00e0y nh\u1eb1m <\/span><b>\u0111\u01a1n gi\u1ea3n h\u00f3a vi\u1ec7c truy c\u1eadp d\u1eef li\u1ec7u<\/b><span style=\"font-weight: 400;\"> t\u1eeb nhi\u1ec1u lo\u1ea1i ngu\u1ed3n l\u01b0u tr\u1eef kh\u00e1c nhau, c\u1ea3 c\u01a1 s\u1edf d\u1eef li\u1ec7u quan h\u1ec7 (Relational) v\u00e0 NoSQL.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>C\u00e1ch ho\u1ea1t \u0111\u1ed9ng:<\/b><span style=\"font-weight: 400;\"> Cung c\u1ea5p m\u1ed9t m\u00f4 h\u00ecnh l\u1eadp tr\u00ecnh nh\u1ea5t qu\u00e1n d\u1ef1a tr\u00ean kh\u00e1i ni\u1ec7m <\/span><b>Repository<\/b><span style=\"font-weight: 400;\">. B\u1ea1n ch\u1ec9 c\u1ea7n \u0111\u1ecbnh ngh\u0129a m\u1ed9t interface k\u1ebf th\u1eeba t\u1eeb c\u00e1c interface Repository c\u1ee7a Spring Data (nh\u01b0 <\/span><span style=\"font-weight: 400;\">JpaRepository<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">MongoRepository<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">CrudRepository<\/span><span style=\"font-weight: 400;\">), v\u00e0 Spring Data s\u1ebd t\u1ef1 \u0111\u1ed9ng t\u1ea1o ra c\u00e1c c\u00e0i \u0111\u1eb7t (implementation) cho c\u00e1c ph\u01b0\u01a1ng th\u1ee9c truy v\u1ea5n d\u1eef li\u1ec7u c\u01a1 b\u1ea3n (CRUD &#8211; Create, Read, Update, Delete) v\u00e0 th\u1eadm ch\u00ed c\u1ea3 c\u00e1c truy v\u1ea5n ph\u1ee9c t\u1ea1p d\u1ef1a tr\u00ean t\u00ean ph\u01b0\u01a1ng th\u1ee9c ho\u1eb7c annotation <\/span><span style=\"font-weight: 400;\">@Query<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u1ee3i \u00edch:<\/b><span style=\"font-weight: 400;\"> Gi\u1ea3m \u0111\u00e1ng k\u1ec3 l\u01b0\u1ee3ng m\u00e3 boilerplate c\u1ea7n vi\u1ebft cho t\u1ea7ng truy c\u1eadp d\u1eef li\u1ec7u.<\/span><\/li>\n<\/ul>\n<h3><b>Spring Security<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">\u0110\u00e2y l\u00e0 m\u1ed9t framework m\u1ea1nh m\u1ebd v\u00e0 t\u00f9y bi\u1ebfn cao \u0111\u1ec3 cung c\u1ea5p c\u00e1c g<\/span><b>i\u1ea3i ph\u00e1p x\u00e1c th\u1ef1c <\/b><span style=\"font-weight: 400;\">(authentication &#8211; ai l\u00e0 ng\u01b0\u1eddi d\u00f9ng?) v\u00e0 ph\u00e2n quy\u1ec1n (authorization &#8211; ng\u01b0\u1eddi d\u00f9ng \u0111\u01b0\u1ee3c l\u00e0m g\u00ec?) cho \u1ee9ng d\u1ee5ng Java, \u0111\u1eb7c bi\u1ec7t l\u00e0 c\u00e1c \u1ee9ng d\u1ee5ng Spring. N\u00f3 b\u1ea3o v\u1ec7 \u1ee9ng d\u1ee5ng kh\u1ecfi c\u00e1c m\u1ed1i \u0111e d\u1ecda b\u1ea3o m\u1eadt ph\u1ed5 bi\u1ebfn nh\u01b0 CSRF, Session Fixation&#8230;<\/span><\/p>\n<h3><b>Spring Cloud<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">D\u1ef1 \u00e1n n\u00e0y cung c\u1ea5p c\u00e1c c\u00f4ng c\u1ee5 v\u00e0 framework \u0111\u1ec3 <\/span><b>x\u00e2y d\u1ef1ng c\u00e1c h\u1ec7 th\u1ed1ng ph\u00e2n t\u00e1n v\u00e0 ki\u1ebfn tr\u00fac microservices<\/b><span style=\"font-weight: 400;\"> m\u1ed9t c\u00e1ch hi\u1ec7u qu\u1ea3 tr\u00ean n\u1ec1n t\u1ea3ng Spring Boot. N\u00f3 gi\u1ea3i quy\u1ebft c\u00e1c th\u00e1ch th\u1ee9c ph\u1ed5 bi\u1ebfn trong ki\u1ebfn tr\u00fac microservices nh\u01b0:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Configuration Management (Qu\u1ea3n l\u00fd c\u1ea5u h\u00ecnh t\u1eadp trung):<\/b><span style=\"font-weight: 400;\"> Spring Cloud Config.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Service Discovery (Kh\u00e1m ph\u00e1 d\u1ecbch v\u1ee5):<\/b><span style=\"font-weight: 400;\"> T\u00edch h\u1ee3p v\u1edbi Eureka, Consul.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Circuit Breakers (Ng\u1eaft m\u1ea1ch):<\/b><span style=\"font-weight: 400;\"> Resilience4j (tr\u01b0\u1edbc \u0111\u00e2y l\u00e0 Hystrix).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Intelligent Routing (\u0110\u1ecbnh tuy\u1ebfn th\u00f4ng minh):<\/b><span style=\"font-weight: 400;\"> Spring Cloud Gateway, Zuul.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Distributed Tracing (Theo d\u00f5i ph\u00e2n t\u00e1n):<\/b><span style=\"font-weight: 400;\"> Spring Cloud Sleuth (t\u00edch h\u1ee3p Zipkin).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><i><span style=\"font-weight: 400;\">V\u00e0 nhi\u1ec1u m\u1eabu h\u00ecnh kh\u00e1c&#8230;<\/span><\/i><\/li>\n<\/ul>\n<h3><b>Spring Batch<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Cung c\u1ea5p m\u1ed9t framework to\u00e0n di\u1ec7n, nh\u1eb9 nh\u00e0ng \u0111\u1ec3 <\/span><b>ph\u00e1t tri\u1ec3n c\u00e1c \u1ee9ng d\u1ee5ng x\u1eed l\u00fd h\u00e0ng lo\u1ea1t (batch processing)<\/b><span style=\"font-weight: 400;\"> m\u1ea1nh m\u1ebd, c\u1ea7n thi\u1ebft cho vi\u1ec7c x\u1eed l\u00fd m\u1ed9t l\u01b0\u1ee3ng l\u1edbn d\u1eef li\u1ec7u theo l\u1ecbch tr\u00ecnh ho\u1eb7c theo y\u00eau c\u1ea7u (v\u00ed d\u1ee5: x\u1eed l\u00fd b\u00e1o c\u00e1o cu\u1ed1i ng\u00e0y, \u0111\u1ecdc\/ghi d\u1eef li\u1ec7u t\u1eeb file l\u1edbn, di chuy\u1ec3n d\u1eef li\u1ec7u&#8230;).<\/span><\/p>\n<h3><b>C\u00e1c d\u1ef1 \u00e1n \u0111\u00e1ng ch\u00fa \u00fd kh\u00e1c<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">H\u1ec7 sinh th\u00e1i Spring c\u00f2n r\u1ea5t nhi\u1ec1u d\u1ef1 \u00e1n h\u1eefu \u00edch kh\u00e1c, v\u00ed d\u1ee5:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Spring Integration:<\/b><span style=\"font-weight: 400;\"> H\u1ed7 tr\u1ee3 tri\u1ec3n khai c\u00e1c m\u1eabu t\u00edch h\u1ee3p doanh nghi\u1ec7p (Enterprise Integration Patterns &#8211; EIP) \u0111\u1ec3 k\u1ebft n\u1ed1i c\u00e1c h\u1ec7 th\u1ed1ng kh\u00e1c nhau.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Spring GraphQL:<\/b><span style=\"font-weight: 400;\"> Cung c\u1ea5p h\u1ed7 tr\u1ee3 x\u00e2y d\u1ef1ng c\u00e1c API GraphQL v\u1edbi Spring.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Spring Session:<\/b><span style=\"font-weight: 400;\"> Qu\u1ea3n l\u00fd session c\u1ee7a ng\u01b0\u1eddi d\u00f9ng m\u1ed9t c\u00e1ch linh ho\u1ea1t, c\u00f3 th\u1ec3 l\u01b0u tr\u1eef session trong Redis, JDBC&#8230; \u0111\u1ec3 h\u1ed7 tr\u1ee3 c\u00e1c \u1ee9ng d\u1ee5ng ph\u00e2n t\u00e1n.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Spring AMQP\/Kafka:<\/b><span style=\"font-weight: 400;\"> H\u1ed7 tr\u1ee3 t\u00edch h\u1ee3p v\u1edbi c\u00e1c h\u1ec7 th\u1ed1ng message broker nh\u01b0 RabbitMQ v\u00e0 Kafka.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Spring HATEOAS:<\/b><span style=\"font-weight: 400;\"> Gi\u00fap x\u00e2y d\u1ef1ng c\u00e1c API RESTful theo nguy\u00ean t\u1eafc HATEOAS.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">S\u1ef1 phong ph\u00fa c\u1ee7a h\u1ec7 sinh th\u00e1i n\u00e0y cho th\u1ea5y kh\u1ea3 n\u0103ng \u0111\u00e1p \u1ee9ng c\u1ee7a Spring \u0111\u1ed1i v\u1edbi h\u1ea7u h\u1ebft c\u00e1c nhu c\u1ea7u ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng Java hi\u1ec7n \u0111\u1ea1i, t\u1eeb c\u00e1c \u1ee9ng d\u1ee5ng web \u0111\u01a1n gi\u1ea3n \u0111\u1ebfn c\u00e1c h\u1ec7 th\u1ed1ng microservices ph\u1ee9c t\u1ea1p tr\u00ean n\u1ec1n t\u1ea3ng \u0111\u00e1m m\u00e2y.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Cac_cau_hoi_thuong_gap_ve_Spring_framework\"><\/span><b>C\u00e1c c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 Spring framework<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>T\u1ea1i sao l\u1ea1i c\u1ea7n IoC\/DI? N\u00f3 gi\u1ea3i quy\u1ebft v\u1ea5n \u0111\u1ec1 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">IoC\/DI gi\u1ea3i quy\u1ebft v\u1ea5n \u0111\u1ec1 <\/span><b>qu\u1ea3n l\u00fd s\u1ef1 ph\u1ee5 thu\u1ed9c (dependency management)<\/b><span style=\"font-weight: 400;\"> v\u00e0 <\/span><b>gi\u1ea3m s\u1ef1 k\u1ebft d\u00ednh (coupling)<\/b><span style=\"font-weight: 400;\"> gi\u1eefa c\u00e1c th\u00e0nh ph\u1ea7n trong \u1ee9ng d\u1ee5ng.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Tr\u01b0\u1edbc IoC\/DI:<\/b><span style=\"font-weight: 400;\"> M\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng ph\u1ea3i t\u1ef1 t\u1ea1o ho\u1eb7c t\u1ef1 t\u00ecm ki\u1ebfm c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng kh\u00e1c m\u00e0 n\u00f3 c\u1ea7n. \u0110i\u1ec1u n\u00e0y t\u1ea1o ra s\u1ef1 ph\u1ee5 thu\u1ed9c c\u1ee9ng, l\u00e0m code kh\u00f3 thay \u0111\u1ed5i, kh\u00f3 m\u1edf r\u1ed9ng v\u00e0 \u0111\u1eb7c bi\u1ec7t l\u00e0 r\u1ea5t kh\u00f3 \u0111\u1ec3 vi\u1ebft unit test (v\u00ec b\u1ea1n kh\u00f4ng th\u1ec3 d\u1ec5 d\u00e0ng thay th\u1ebf dependency b\u1eb1ng m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng gi\u1ea3 l\u1eadp &#8211; mock).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>V\u1edbi IoC\/DI:<\/b><span style=\"font-weight: 400;\"> \u0110\u1ed1i t\u01b0\u1ee3ng kh\u00f4ng t\u1ef1 t\u1ea1o dependency n\u1eefa, m\u00e0 \u0111\u01b0\u1ee3c &#8220;ti\u00eam&#8221; t\u1eeb b\u00ean ngo\u00e0i (b\u1edfi IoC Container). \u0110i\u1ec1u n\u00e0y l\u00e0m cho c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng tr\u1edf n\u00ean \u0111\u1ed9c l\u1eadp h\u01a1n, d\u1ec5 d\u00e0ng thay th\u1ebf dependency (v\u00ed d\u1ee5, thay \u0111\u1ed5i t\u1eeb database n\u00e0y sang database kh\u00e1c, ho\u1eb7c d\u00f9ng mock object khi test), gi\u00fap code linh ho\u1ea1t, d\u1ec5 b\u1ea3o tr\u00ec v\u00e0 d\u1ec5 ki\u1ec3m th\u1eed h\u01a1n r\u1ea5t nhi\u1ec1u.<\/span><\/li>\n<\/ul>\n<h3><b>Spring c\u00f3 ph\u1ea3i l\u00e0 s\u1ef1 thay th\u1ebf ho\u00e0n to\u00e0n cho Java EE \/ Jakarta EE kh\u00f4ng?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Kh\u00f4ng h\u1eb3n l\u00e0 &#8220;thay th\u1ebf ho\u00e0n to\u00e0n&#8221; m\u00e0 gi\u1ed1ng nh\u01b0 m\u1ed9t <\/span><b>gi\u1ea3i ph\u00e1p thay th\u1ebf v\u00e0 b\u1ed5 sung ph\u1ed5 bi\u1ebfn<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Spring ban \u0111\u1ea7u ra \u0111\u1eddi \u0111\u1ec3 gi\u1ea3i quy\u1ebft s\u1ef1 ph\u1ee9c t\u1ea1p c\u1ee7a EJB 2.x (m\u1ed9t ph\u1ea7n c\u1ee7a Java EE c\u0169).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Spring Framework cung c\u1ea5p nhi\u1ec1u ch\u1ee9c n\u0103ng t\u01b0\u01a1ng t\u1ef1 Java EE\/Jakarta EE (nh\u01b0 web framework, dependency injection, transaction management) nh\u01b0ng th\u01b0\u1eddng theo m\u1ed9t c\u00e1ch ti\u1ebfp c\u1eadn kh\u00e1c (POJO-based, linh ho\u1ea1t h\u01a1n).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Spring t\u00edch h\u1ee3p r\u1ea5t t\u1ed1t v\u1edbi nhi\u1ec1u chu\u1ea9n c\u1ee7a Jakarta EE (v\u00ed d\u1ee5: Servlet API, JPA, Bean Validation).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Nhi\u1ec1u \u1ee9ng d\u1ee5ng hi\u1ec7n \u0111\u1ea1i s\u1eed d\u1ee5ng Spring Boot l\u00e0m n\u1ec1n t\u1ea3ng ch\u00ednh thay v\u00ec d\u1ef1a ho\u00e0n to\u00e0n v\u00e0o m\u1ed9t Application Server chu\u1ea9n Jakarta EE.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Spring l\u00e0 m\u1ed9t l\u1ef1a ch\u1ecdn r\u1ea5t m\u1ea1nh m\u1ebd v\u00e0 ph\u1ed5 bi\u1ebfn, th\u01b0\u1eddng \u0111\u01b0\u1ee3c d\u00f9ng thay th\u1ebf ho\u1eb7c song song v\u1edbi c\u00e1c th\u00e0nh ph\u1ea7n c\u1ee7a Jakarta EE<\/span><\/p>\n<h3><b>S\u1eed d\u1ee5ng Spring Framework c\u00f3 t\u1ed1n ph\u00ed kh\u00f4ng?<\/b><\/h3>\n<p><b>Kh\u00f4ng.<\/b><span style=\"font-weight: 400;\"> Spring Framework v\u00e0 h\u1ea7u h\u1ebft c\u00e1c d\u1ef1 \u00e1n trong h\u1ec7 sinh th\u00e1i c\u1ee7a n\u00f3 (Spring Boot, Spring Data, Spring Security&#8230;) \u0111\u1ec1u l\u00e0 <\/span><b>m\u00e3 ngu\u1ed3n m\u1edf (open-source)<\/b><span style=\"font-weight: 400;\"> theo gi\u1ea5y ph\u00e9p Apache 2.0, ngh\u0129a l\u00e0 b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng ch\u00fang ho\u00e0n to\u00e0n mi\u1ec5n ph\u00ed cho c\u1ea3 m\u1ee5c \u0111\u00edch c\u00e1 nh\u00e2n v\u00e0 th\u01b0\u01a1ng m\u1ea1i.<\/span><\/p>\n<h3><b>Spring Framework v\u00e0 Spring Boot kh\u00e1c nhau nh\u01b0 th\u1ebf n\u00e0o?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Spring Framework:<\/b><span style=\"font-weight: 400;\"> L\u00e0 n\u1ec1n t\u1ea3ng c\u1ed1t l\u00f5i, cung c\u1ea5p c\u00e1c t\u00ednh n\u0103ng c\u01a1 b\u1ea3n nh\u01b0 IoC Container, DI, AOP, qu\u1ea3n l\u00fd transaction, v\u00e0 c\u00e1c module t\u00edch h\u1ee3p (Data Access, Web MVC&#8230;). N\u00f3 gi\u1ed1ng nh\u01b0 b\u1ed9 khung x\u01b0\u01a1ng v\u00e0 c\u00e1c b\u1ed9 ph\u1eadn c\u01a1 b\u1ea3n.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Spring Boot:<\/b><span style=\"font-weight: 400;\"> L\u00e0 m\u1ed9t d\u1ef1 \u00e1n x\u00e2y d\u1ef1ng <\/span><i><span style=\"font-weight: 400;\">tr\u00ean n\u1ec1n<\/span><\/i><span style=\"font-weight: 400;\"> Spring Framework, v\u1edbi m\u1ee5c ti\u00eau ch\u00ednh l\u00e0 \u0111\u01a1n gi\u1ea3n h\u00f3a vi\u1ec7c thi\u1ebft l\u1eadp, c\u1ea5u h\u00ecnh v\u00e0 ch\u1ea1y \u1ee9ng d\u1ee5ng Spring. N\u00f3 cung c\u1ea5p auto-configuration, embedded servers, v\u00e0 c\u00e1c c\u1ea5u h\u00ecnh m\u1eb7c \u0111\u1ecbnh h\u1ee3p l\u00fd (&#8220;opinionated defaults&#8221;). H\u00e3y ngh\u0129 v\u1ec1 Spring Boot nh\u01b0 m\u1ed9t chi\u1ebfc xe \u0111\u00e3 \u0111\u01b0\u1ee3c l\u1eafp r\u00e1p s\u1eb5n t\u1eeb c\u00e1c b\u1ed9 ph\u1eadn c\u1ee7a Spring Framework, b\u1ea1n ch\u1ec9 c\u1ea7n kh\u1edfi \u0111\u1ed9ng v\u00e0 l\u00e1i.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Tong_ket\"><\/span><b>T\u1ed5ng k\u1ebft<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Qua b\u00e0i vi\u1ebft n\u00e0y, ch\u00fang ta \u0111\u00e3 c\u00f9ng nhau kh\u00e1m ph\u00e1 <\/span><b>Spring Framework<\/b><span style=\"font-weight: 400;\"> &#8211; kh\u00f4ng ch\u1ec9 l\u00e0 m\u1ed9t framework \u0111\u01a1n thu\u1ea7n m\u00e0 l\u00e0 c\u1ea3 m\u1ed9t h\u1ec7 sinh th\u00e1i m\u1ea1nh m\u1ebd v\u00e0 to\u00e0n di\u1ec7n, \u0111\u00f3ng vai tr\u00f2 n\u1ec1n t\u1ea3ng v\u1eefng ch\u1eafc cho vi\u1ec7c ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng Java hi\u1ec7n \u0111\u1ea1i. D\u00f9 b\u1ea1n l\u00e0 ng\u01b0\u1eddi m\u1edbi b\u1eaft \u0111\u1ea7u hay \u0111\u00e3 l\u00e0 m\u1ed9t l\u1eadp tr\u00ecnh vi\u00ean Java d\u00e0y d\u1ea1n kinh nghi\u1ec7m, vi\u1ec7c hi\u1ec3u v\u00e0 s\u1eed d\u1ee5ng th\u00e0nh th\u1ea1o Spring Framework v\u00e0 c\u00e1c d\u1ef1 \u00e1n li\u00ean quan ch\u1eafc ch\u1eafn s\u1ebd mang l\u1ea1i l\u1ee3i th\u1ebf l\u1edbn. N\u00f3 kh\u00f4ng ch\u1ec9 gi\u00fap b\u1ea1n x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng ch\u1ea5t l\u01b0\u1ee3ng cao, d\u1ec5 b\u1ea3o tr\u00ec, d\u1ec5 m\u1edf r\u1ed9ng m\u00e0 c\u00f2n m\u1edf ra nhi\u1ec1u c\u01a1 h\u1ed9i ngh\u1ec1 nghi\u1ec7p trong th\u1ebf gi\u1edbi c\u00f4ng ngh\u1ec7 kh\u00f4ng ng\u1eebng ph\u00e1t tri\u1ec3n.<\/span><\/p>\n<blockquote><p><em>\u0110\u1ecdc th\u00eam: <a href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-java\/\" target=\"_blank\" rel=\"noopener\"><strong>Top 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Java nh\u1ea5t \u0111\u1ecbnh c\u00f3 trong bu\u1ed5i ph\u1ecfng v\u1ea5n<\/strong><\/a><\/em><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Trong h\u1ec7 sinh th\u00e1i ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng Java, Spring Framework l\u00e0 m\u1ed9t framework m\u00e3 ngu\u1ed3n m\u1edf m\u1ea1nh m\u1ebd v\u00e0 \u0111\u01b0\u1ee3c \u01b0a chu\u1ed9ng b\u1eadc nh\u1ea5t hi\u1ec7n nay. M\u1ee5c ti\u00eau ch\u00ednh c\u1ee7a Spring l\u00e0 gi\u00fap \u0111\u01a1n gi\u1ea3n h\u00f3a qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n, gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean Java x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng d\u1ec5 b\u1ea3o tr\u00ec, d\u1ec5 [&hellip;]<\/p>\n","protected":false},"author":203,"featured_media":61311,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","footnotes":""},"categories":[109],"tags":[],"class_list":["post-86530","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chuyen-mon-it"],"blocksy_meta":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v27.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Spring Framework v\u00e0 h\u1ec7 sinh th\u00e1i v\u1eefng ch\u1eafc cho \u1ee9ng d\u1ee5ng Java - ITviec Blog<\/title>\n<meta name=\"description\" content=\"Kh\u00e1m ph\u00e1 Spring Framework v\u00e0 h\u1ec7 sinh th\u00e1i Spring, t\u1eeb kh\u00e1i ni\u1ec7m c\u1ed1t l\u00f5i, module, \u01b0u nh\u01b0\u1ee3c \u0111i\u1ec3m \u0111\u1ebfn code Java d\u1ec5 b\u1ea3o tr\u00ec v\u00e0 ki\u1ec3m th\u1eed.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itviec.com\/blog\/spring-framework\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Framework v\u00e0 h\u1ec7 sinh th\u00e1i v\u1eefng ch\u1eafc cho \u1ee9ng d\u1ee5ng Java\" \/>\n<meta property=\"og:description\" content=\"Trong h\u1ec7 sinh th\u00e1i ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng Java, Spring Framework l\u00e0 m\u1ed9t framework m\u00e3 ngu\u1ed3n m\u1edf m\u1ea1nh m\u1ebd v\u00e0 \u0111\u01b0\u1ee3c \u01b0a chu\u1ed9ng b\u1eadc nh\u1ea5t hi\u1ec7n nay. M\u1ee5c ti\u00eau ch\u00ednh c\u1ee7a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/spring-framework\/\" \/>\n<meta property=\"og:site_name\" content=\"ITviec Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ITviec\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-02T07:33:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/02\/spring-framework-blog-thumbnail-vippro.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"950\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Tien Tran\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ITviec\" \/>\n<meta name=\"twitter:site\" content=\"@ITviec\" \/>\n<meta name=\"twitter:label1\" content=\"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tien Tran\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data2\" content=\"28 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Spring Framework v\u00e0 h\u1ec7 sinh th\u00e1i v\u1eefng ch\u1eafc cho \u1ee9ng d\u1ee5ng Java - ITviec Blog","description":"Kh\u00e1m ph\u00e1 Spring Framework v\u00e0 h\u1ec7 sinh th\u00e1i Spring, t\u1eeb kh\u00e1i ni\u1ec7m c\u1ed1t l\u00f5i, module, \u01b0u nh\u01b0\u1ee3c \u0111i\u1ec3m \u0111\u1ebfn code Java d\u1ec5 b\u1ea3o tr\u00ec v\u00e0 ki\u1ec3m th\u1eed.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itviec.com\/blog\/spring-framework\/","og_locale":"vi_VN","og_type":"article","og_title":"Spring Framework v\u00e0 h\u1ec7 sinh th\u00e1i v\u1eefng ch\u1eafc cho \u1ee9ng d\u1ee5ng Java","og_description":"Trong h\u1ec7 sinh th\u00e1i ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng Java, Spring Framework l\u00e0 m\u1ed9t framework m\u00e3 ngu\u1ed3n m\u1edf m\u1ea1nh m\u1ebd v\u00e0 \u0111\u01b0\u1ee3c \u01b0a chu\u1ed9ng b\u1eadc nh\u1ea5t hi\u1ec7n nay. M\u1ee5c ti\u00eau ch\u00ednh c\u1ee7a","og_url":"https:\/\/itviec.com\/blog\/spring-framework\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2025-05-02T07:33:34+00:00","og_image":[{"width":950,"height":500,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/02\/spring-framework-blog-thumbnail-vippro.jpg","type":"image\/jpeg"}],"author":"Tien Tran","twitter_card":"summary_large_image","twitter_creator":"@ITviec","twitter_site":"@ITviec","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"Tien Tran","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"28 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/spring-framework\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/spring-framework\/"},"author":{"name":"Tien Tran","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/1595d671c49cfa2a48cd3c0a047a1298"},"headline":"Spring Framework v\u00e0 h\u1ec7 sinh th\u00e1i v\u1eefng ch\u1eafc cho \u1ee9ng d\u1ee5ng Java","datePublished":"2025-05-02T07:33:34+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/spring-framework\/"},"wordCount":7407,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/spring-framework\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/02\/spring-framework-blog-thumbnail-vippro.jpg","articleSection":["Chuy\u00ean m\u00f4n IT"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/spring-framework\/","url":"https:\/\/itviec.com\/blog\/spring-framework\/","name":"Spring Framework v\u00e0 h\u1ec7 sinh th\u00e1i v\u1eefng ch\u1eafc cho \u1ee9ng d\u1ee5ng Java - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/spring-framework\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/spring-framework\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/02\/spring-framework-blog-thumbnail-vippro.jpg","datePublished":"2025-05-02T07:33:34+00:00","description":"Kh\u00e1m ph\u00e1 Spring Framework v\u00e0 h\u1ec7 sinh th\u00e1i Spring, t\u1eeb kh\u00e1i ni\u1ec7m c\u1ed1t l\u00f5i, module, \u01b0u nh\u01b0\u1ee3c \u0111i\u1ec3m \u0111\u1ebfn code Java d\u1ec5 b\u1ea3o tr\u00ec v\u00e0 ki\u1ec3m th\u1eed.","breadcrumb":{"@id":"https:\/\/itviec.com\/blog\/spring-framework\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/spring-framework\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/spring-framework\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/02\/spring-framework-blog-thumbnail-vippro.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/02\/spring-framework-blog-thumbnail-vippro.jpg","width":950,"height":500,"caption":"spring framework l\u00e0 g\u00ec itviec blog"},{"@type":"BreadcrumbList","@id":"https:\/\/itviec.com\/blog\/spring-framework\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Chuy\u00ean m\u00f4n IT","item":"https:\/\/itviec.com\/blog\/chuyen-mon-it\/"},{"@type":"ListItem","position":2,"name":"Spring Framework v\u00e0 h\u1ec7 sinh th\u00e1i v\u1eefng ch\u1eafc cho \u1ee9ng d\u1ee5ng Java"}]},{"@type":"WebSite","@id":"https:\/\/itviec.com\/blog\/#website","url":"https:\/\/itviec.com\/blog\/","name":"ITviec Blog","description":"IT Jobs &amp; People in Vietnam","publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itviec.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"vi"},{"@type":"Organization","@id":"https:\/\/itviec.com\/blog\/#organization","name":"ITviec","url":"https:\/\/itviec.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","width":1800,"height":1800,"caption":"ITviec"},"image":{"@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ITviec","https:\/\/x.com\/ITviec","https:\/\/www.linkedin.com\/company\/itviec","https:\/\/www.youtube.com\/channel\/UCYthAQ3bcGr57M_ag5gHDvQ"]},{"@type":"Person","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/1595d671c49cfa2a48cd3c0a047a1298","name":"Tien Tran","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/05\/tien-tran-author-e1715658627643-100x100.jpg","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/05\/tien-tran-author-e1715658627643-100x100.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/05\/tien-tran-author-e1715658627643-100x100.jpg","caption":"Tien Tran"},"url":"https:\/\/itviec.com\/blog\/author\/tien-tran\/"}]}},"_links":{"self":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/86530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/users\/203"}],"replies":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/comments?post=86530"}],"version-history":[{"count":0,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/86530\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/61311"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=86530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=86530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=86530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}