{"id":98713,"date":"2019-09-30T07:00:23","date_gmt":"2019-09-30T04:00:23","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=98713"},"modified":"2019-09-27T11:32:05","modified_gmt":"2019-09-27T08:32:05","slug":"spring-lazy-annotation","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html","title":{"rendered":"Spring @Lazy Annotation"},"content":{"rendered":"<h3 class=\"wp-block-heading\">Introduction:<\/h3>\n<p>The Spring framework,<strong> by default, loads and eagerly initializes all beans at the application startup itself.<\/strong> In our application, we might have some pretty resource-intensive beans. We\u2019ll prefer to load such beans on a need basis. We can achieve this using the Spring <em>@Lazy<\/em> annotation.<\/p>\n<p>In this tutorial, we\u2019ll learn how to use <em>@Lazy<\/em> annotation to lazily load our beans.<\/p>\n<h3 class=\"wp-block-heading\">Lazy Initialization:<\/h3>\n<p><strong>If we mark our Spring configuration class with<em> @Lazy<\/em> annotation, then all defined beans with <em>@Bean <\/em>annotation will get lazily loaded:<\/strong><\/p>\n<div>\n<div id=\"highlighter_414870\" class=\"syntaxhighlighter  java\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">01<\/div>\n<div class=\"line number2 index1 alt1\">02<\/div>\n<div class=\"line number3 index2 alt2\">03<\/div>\n<div class=\"line number4 index3 alt1\">04<\/div>\n<div class=\"line number5 index4 alt2\">05<\/div>\n<div class=\"line number6 index5 alt1\">06<\/div>\n<div class=\"line number7 index6 alt2\">07<\/div>\n<div class=\"line number8 index7 alt1\">08<\/div>\n<div class=\"line number9 index8 alt2\">09<\/div>\n<div class=\"line number10 index9 alt1\">10<\/div>\n<div class=\"line number11 index10 alt2\">11<\/div>\n<div class=\"line number12 index11 alt1\">12<\/div>\n<div class=\"line number13 index12 alt2\">13<\/div>\n<div class=\"line number14 index13 alt1\">14<\/div>\n<div class=\"line number15 index14 alt2\">15<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"java color1\">@Configuration<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"java color1\">@ComponentScan<\/code><code class=\"java plain\">(basePackages = <\/code><code class=\"java string\">\"com.programmergirl.university\"<\/code><code class=\"java plain\">)<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"java color1\">@Lazy<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"java keyword\">public<\/code> <code class=\"java keyword\">class<\/code> <code class=\"java plain\">AppConfig {<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"java spaces\">&nbsp;<\/code>&nbsp;<\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java color1\">@Bean<\/code><\/div>\n<div class=\"line number7 index6 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">public<\/code> <code class=\"java plain\">Student student() {<\/code><\/div>\n<div class=\"line number8 index7 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">return<\/code> <code class=\"java keyword\">new<\/code> <code class=\"java plain\">Student();<\/code><\/div>\n<div class=\"line number9 index8 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">}<\/code><\/div>\n<div class=\"line number10 index9 alt1\"><code class=\"java spaces\">&nbsp;<\/code>&nbsp;<\/div>\n<div class=\"line number11 index10 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java color1\">@Bean<\/code><\/div>\n<div class=\"line number12 index11 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">public<\/code> <code class=\"java plain\">Teacher teacher() {<\/code><\/div>\n<div class=\"line number13 index12 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">return<\/code> <code class=\"java keyword\">new<\/code> <code class=\"java plain\">Teacher();<\/code><\/div>\n<div class=\"line number14 index13 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">}<\/code><\/div>\n<div class=\"line number15 index14 alt2\"><code class=\"java plain\">}<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>We can also lazy load just a single bean by using this annotation at the method level:<\/p>\n<div>\n<div id=\"highlighter_74363\" class=\"syntaxhighlighter  java\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"java color1\">@Bean<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"java color1\">@Lazy<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"java keyword\">public<\/code> <code class=\"java plain\">Teacher teacher() {<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">return<\/code> <code class=\"java keyword\">new<\/code> <code class=\"java plain\">Teacher();<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"java plain\">}<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3 class=\"wp-block-heading\">Testing Lazy Loading:<\/h3>\n<p>Let\u2019s quickly test out this functionality by running our application:<\/p>\n<div>\n<div id=\"highlighter_470783\" class=\"syntaxhighlighter  java\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">01<\/div>\n<div class=\"line number2 index1 alt1\">02<\/div>\n<div class=\"line number3 index2 alt2\">03<\/div>\n<div class=\"line number4 index3 alt1\">04<\/div>\n<div class=\"line number5 index4 alt2\">05<\/div>\n<div class=\"line number6 index5 alt1\">06<\/div>\n<div class=\"line number7 index6 alt2\">07<\/div>\n<div class=\"line number8 index7 alt1\">08<\/div>\n<div class=\"line number9 index8 alt2\">09<\/div>\n<div class=\"line number10 index9 alt1\">10<\/div>\n<div class=\"line number11 index10 alt2\">11<\/div>\n<div class=\"line number12 index11 alt1\">12<\/div>\n<div class=\"line number13 index12 alt2\">13<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"java keyword\">public<\/code> <code class=\"java keyword\">class<\/code> <code class=\"java plain\">SampleApp {<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">private<\/code> <code class=\"java keyword\">static<\/code> <code class=\"java keyword\">final<\/code> <code class=\"java plain\">Logger LOG = Logger.getLogger(SampleApp.<\/code><code class=\"java keyword\">class<\/code><code class=\"java plain\">);<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">public<\/code> <code class=\"java keyword\">static<\/code> <code class=\"java keyword\">void<\/code> <code class=\"java plain\">main(String args[]) {<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">AnnotationConfigApplicationContext context = <\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">new<\/code> <code class=\"java plain\">AnnotationConfigApplicationContext(AppConfig.<\/code><code class=\"java keyword\">class<\/code><code class=\"java plain\">);<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code>&nbsp;<\/div>\n<div class=\"line number7 index6 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">LOG.info(<\/code><code class=\"java string\">\"Application Context is already up\"<\/code><code class=\"java plain\">);<\/code><\/div>\n<div class=\"line number8 index7 alt1\"><code class=\"java spaces\">&nbsp;<\/code>&nbsp;<\/div>\n<div class=\"line number9 index8 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java comments\">\/\/ Beans in our Config class lazily loaded<\/code><\/div>\n<div class=\"line number10 index9 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">Teacher teacherLazilyLoaded = context.getBean(Teacher.<\/code><code class=\"java keyword\">class<\/code><code class=\"java plain\">);<\/code><\/div>\n<div class=\"line number11 index10 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">Student studentLazilyLoaded = context.getBean(Student.<\/code><code class=\"java keyword\">class<\/code><code class=\"java plain\">);<\/code><\/div>\n<div class=\"line number12 index11 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">}<\/code><\/div>\n<div class=\"line number13 index12 alt2\"><code class=\"java plain\">}<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>On our console, we\u2019ll see:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<div>\n<div id=\"highlighter_675941\" class=\"syntaxhighlighter  shell\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<div class=\"line number6 index5 alt1\">6<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"shell plain\">Bean factory <\/code><code class=\"shell keyword\">for<\/code> <code class=\"shell plain\">...AnnotationConfigApplicationContext: <\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"shell plain\">...DefaultListableBeanFactory: [...]<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"shell plain\">...<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"shell plain\">Application Context is already up<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"shell plain\">Inside Teacher Constructor<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"shell plain\">Inside Student Constructor<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>Clearly, <strong>Spring initialized both <em>Student<\/em> and <em>Teacher<\/em> beans on demand and not while setting up the application context.<\/strong><\/p>\n<h3 class=\"wp-block-heading\">With <em>@Autowired<\/em>&nbsp;Annotation:<\/h3>\n<p><strong>We can also use <em>@Lazy<\/em> annotation at an injection point: constructor, setter or field-level.&nbsp;<\/strong><\/p>\n<p>Let\u2019s say we have a <em>Classroom<\/em> class that we want to lazy-load:<\/p>\n<div>\n<div id=\"highlighter_490560\" class=\"syntaxhighlighter  java\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<div class=\"line number6 index5 alt1\">6<\/div>\n<div class=\"line number7 index6 alt2\">7<\/div>\n<div class=\"line number8 index7 alt1\">8<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"java color1\">@Component<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"java color1\">@Lazy<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"java keyword\">public<\/code> <code class=\"java keyword\">class<\/code> <code class=\"java plain\">Classroom {<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">public<\/code> <code class=\"java plain\">Classroom() {<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">System.out.println(<\/code><code class=\"java string\">\"Inside Classroom Constructor\"<\/code><code class=\"java plain\">);<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">}<\/code><\/div>\n<div class=\"line number7 index6 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">...<\/code><\/div>\n<div class=\"line number8 index7 alt1\"><code class=\"java plain\">}<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>And it\u2019s wired to the <em>University<\/em> bean via <em>@Autowired<\/em> annotation:<\/p>\n<div>\n<div id=\"highlighter_252807\" class=\"syntaxhighlighter  java\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">01<\/div>\n<div class=\"line number2 index1 alt1\">02<\/div>\n<div class=\"line number3 index2 alt2\">03<\/div>\n<div class=\"line number4 index3 alt1\">04<\/div>\n<div class=\"line number5 index4 alt2\">05<\/div>\n<div class=\"line number6 index5 alt1\">06<\/div>\n<div class=\"line number7 index6 alt2\">07<\/div>\n<div class=\"line number8 index7 alt1\">08<\/div>\n<div class=\"line number9 index8 alt2\">09<\/div>\n<div class=\"line number10 index9 alt1\">10<\/div>\n<div class=\"line number11 index10 alt2\">11<\/div>\n<div class=\"line number12 index11 alt1\">12<\/div>\n<div class=\"line number13 index12 alt2\">13<\/div>\n<div class=\"line number14 index13 alt1\">14<\/div>\n<div class=\"line number15 index14 alt2\">15<\/div>\n<div class=\"line number16 index15 alt1\">16<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"java color1\">@Component<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"java keyword\">public<\/code> <code class=\"java keyword\">class<\/code> <code class=\"java plain\">University {<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"java spaces\">&nbsp;<\/code>&nbsp;<\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java color1\">@Lazy<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java color1\">@Autowired<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">private<\/code> <code class=\"java plain\">Classroom classroom;<\/code><\/div>\n<div class=\"line number7 index6 alt2\"><code class=\"java spaces\">&nbsp;<\/code>&nbsp;<\/div>\n<div class=\"line number8 index7 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">public<\/code> <code class=\"java plain\">University() {<\/code><\/div>\n<div class=\"line number9 index8 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">System.out.println(<\/code><code class=\"java string\">\"Inside University Constructor\"<\/code><code class=\"java plain\">);<\/code><\/div>\n<div class=\"line number10 index9 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">}<\/code><\/div>\n<div class=\"line number11 index10 alt2\"><code class=\"java spaces\">&nbsp;<\/code>&nbsp;<\/div>\n<div class=\"line number12 index11 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">public<\/code> <code class=\"java keyword\">void<\/code> <code class=\"java plain\">useClassroomBean() {<\/code><\/div>\n<div class=\"line number13 index12 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java keyword\">this<\/code><code class=\"java plain\">.classroom.getDetails(); <\/code><\/div>\n<div class=\"line number14 index13 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">...<\/code><\/div>\n<div class=\"line number15 index14 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">}<\/code><\/div>\n<div class=\"line number16 index15 alt1\"><code class=\"java plain\">}<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>Here, we have lazily-injected the <em>Classroom<\/em> bean.<\/strong> And so, while instantiating a <em>University<\/em> object, Spring will create and map a proxy <em>Classroom<\/em> object to it. Finally, when we invoke <em>useClassroomBean()<\/em>, only then it\u2019ll create the actual <em>Classroom<\/em> instance:<\/p>\n<div>\n<div id=\"highlighter_479355\" class=\"syntaxhighlighter  java\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<div class=\"line number6 index5 alt1\">6<\/div>\n<div class=\"line number7 index6 alt2\">7<\/div>\n<div class=\"line number8 index7 alt1\">8<\/div>\n<div class=\"line number9 index8 alt2\">9<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"java comments\">\/\/ in our main() method<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"java plain\">AnnotationConfigApplicationContext context<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;<\/code><code class=\"java plain\">= <\/code><code class=\"java keyword\">new<\/code> <code class=\"java plain\">AnnotationConfigApplicationContext(); <\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"java spaces\">&nbsp;<\/code>&nbsp;<\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"java plain\">LOG.info(<\/code><code class=\"java string\">\"Application Context is already up\"<\/code><code class=\"java plain\">);<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"java spaces\">&nbsp;<\/code>&nbsp;<\/div>\n<div class=\"line number7 index6 alt2\"><code class=\"java plain\">University university = context.getBean(University.<\/code><code class=\"java keyword\">class<\/code><code class=\"java plain\">);<\/code><\/div>\n<div class=\"line number8 index7 alt1\"><code class=\"java plain\">LOG.info(<\/code><code class=\"java string\">\"Time to use the actual classroom bean...\"<\/code><code class=\"java plain\">);<\/code><\/div>\n<div class=\"line number9 index8 alt2\"><code class=\"java plain\">university.useClassroomBean();<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>The above code will produce the following logs:<\/p>\n<div>\n<div id=\"highlighter_715246\" class=\"syntaxhighlighter  shell\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<div class=\"line number6 index5 alt1\">6<\/div>\n<div class=\"line number7 index6 alt2\">7<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"shell plain\">Bean factory <\/code><code class=\"shell keyword\">for<\/code> <code class=\"shell plain\">...AnnotationConfigApplicationContext:<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"shell spaces\">&nbsp;<\/code><code class=\"shell plain\">...DefaultListableBeanFactory: [...] ...<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"shell plain\">Inside University Constructor<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"shell plain\">... <\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"shell plain\">Application Context is already up<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"shell plain\">Time to use the actual classroom bean...<\/code><\/div>\n<div class=\"line number7 index6 alt2\"><code class=\"shell plain\">Inside Classroom Constructor<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>As we can see, the instantiation of the <em>Classroom<\/em> object gets delayed until its actually needed.<\/p>\n<p><strong>Please note that, for lazy-injection, we must use <em>@Lazy<\/em> annotation on both the component class as well as the injection point.<\/strong><\/p>\n<h3 class=\"wp-block-heading\">Conclusion:<\/h3>\n<p>In this quick tutorial, we learned how to lazy load our Spring beans. We talked about lazy initialization and lazy injection.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Java Code Geeks with permission by Shubhra Srivastava, partner at our <a href=\"\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">JCG program<\/a>. See the original article here: <a href=\"http:\/\/www.programmergirl.com\/spring-lazy-annotation\/\" target=\"_blank\" rel=\"noopener noreferrer\">Spring @Lazy Annotation<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: The Spring framework, by default, loads and eagerly initializes all beans at the application startup itself. In our application, we might have some pretty resource-intensive beans. We\u2019ll prefer to load such beans on a need basis. We can achieve this using the Spring @Lazy annotation. In this tutorial, we\u2019ll learn how to use @Lazy &hellip;<\/p>\n","protected":false},"author":82253,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[30],"class_list":["post-98713","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-spring"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring @Lazy Annotation - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn about Lazy Annotation? Check our article explaining how to use @Lazy annotation to lazily load our beans.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring @Lazy Annotation - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Lazy Annotation? Check our article explaining how to use @Lazy annotation to lazily load our beans.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-30T04:00:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Shubhra Srivastava\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shubhra Srivastava\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html\"},\"author\":{\"name\":\"Shubhra Srivastava\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/b73b076dc62e72de203df7018d398e56\"},\"headline\":\"Spring @Lazy Annotation\",\"datePublished\":\"2019-09-30T04:00:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html\"},\"wordCount\":335,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Spring\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html\",\"name\":\"Spring @Lazy Annotation - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2019-09-30T04:00:23+00:00\",\"description\":\"Interested to learn about Lazy Annotation? Check our article explaining how to use @Lazy annotation to lazily load our beans.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/spring-lazy-annotation.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring @Lazy Annotation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/b73b076dc62e72de203df7018d398e56\",\"name\":\"Shubhra Srivastava\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g\",\"caption\":\"Shubhra Srivastava\"},\"description\":\"Shubhra is a software professional and founder of ProgrammerGirl. She has a great experience with Java\\\/J2EE technologies and frameworks. She loves the amalgam of programming and coffee :)\",\"sameAs\":[\"http:\\\/\\\/www.programmergirl.com\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/shubhra-srivastava224\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/shubhra-srivastava\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring @Lazy Annotation - Java Code Geeks","description":"Interested to learn about Lazy Annotation? Check our article explaining how to use @Lazy annotation to lazily load our beans.","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:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html","og_locale":"en_US","og_type":"article","og_title":"Spring @Lazy Annotation - Java Code Geeks","og_description":"Interested to learn about Lazy Annotation? Check our article explaining how to use @Lazy annotation to lazily load our beans.","og_url":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2019-09-30T04:00:23+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Shubhra Srivastava","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Shubhra Srivastava","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html"},"author":{"name":"Shubhra Srivastava","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/b73b076dc62e72de203df7018d398e56"},"headline":"Spring @Lazy Annotation","datePublished":"2019-09-30T04:00:23+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html"},"wordCount":335,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Spring"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html","url":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html","name":"Spring @Lazy Annotation - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2019-09-30T04:00:23+00:00","description":"Interested to learn about Lazy Annotation? Check our article explaining how to use @Lazy annotation to lazily load our beans.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/spring-lazy-annotation.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring @Lazy Annotation"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/b73b076dc62e72de203df7018d398e56","name":"Shubhra Srivastava","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g","caption":"Shubhra Srivastava"},"description":"Shubhra is a software professional and founder of ProgrammerGirl. She has a great experience with Java\/J2EE technologies and frameworks. She loves the amalgam of programming and coffee :)","sameAs":["http:\/\/www.programmergirl.com","https:\/\/www.linkedin.com\/in\/shubhra-srivastava224\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/shubhra-srivastava"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/98713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/82253"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=98713"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/98713\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=98713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=98713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=98713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}