Science & Technology

#9 Spring XML Config

by Telusko

Share:

📚 Main topics

  • Why use XML configurationThe tutorial creates a Spring project without Spring Boot and explains that XML is useful for maintaining legacy projects and understanding what happens behind Spring Boot. 0:00
  • Defining Spring beansThe XML configuration uses a beans element and bean entries to tell Spring which classes to manage, with each entry specifying a class and an ID. 1:32
  • Adding bean definitionsThe presenter adds definitions for Dev and Laptop, then shows that Spring creates an object for each bean listed when the application context is created. 5:42
  • Repeated bean entriesListing Dev twice with different IDs results in two Dev objects, alongside the Laptop object. 8:51

✨ Key takeaways

  • Spring creates configured objectsCreating the application context makes Spring read the XML and instantiate the classes listed as beans. Classes without bean entries are not created by this configuration. 6:48
  • Bean count follows the configurationEach bean entry results in an object, even when multiple entries refer to the same class. 8:51

🧠 Lessons learned

  • Provide the XML definitionSpring needs the appropriate beans declaration in the XML file to recognize its configuration elements. 4:07
  • Use constructors to check instantiationPrinting a message from each constructor makes it easy to see which objects Spring created. 7:19

🏁 Conclusion/next steps

  • Dependencies are nextThe next video will cover how to provide a Laptop object to Dev, introducing dependencies between objects. 9:22

Transcript excerpt

0:00 welcome back aliens my name is Navin Reddy and let's continue the series on Spring framework now we are basically trying to create a spring project without spring Boot and of course for that we have to do lot of configuration and to achieve that we have basically created the project and in that we do have a Dev class here in which you have a method called build and what we are trying to do is we are trying to call the build but for that we we need object of Dev and then we want spring framework to create the object which is actually not

0:30 happening because if I run this this is what you are getting we were getting the error which says premature end of file uh which file I'm talking about is the spring.xml because if you want spring to create the object we have to do the configuration and this configuration will be done in the XML file and this is empty at this point I don't want this to be empty we have to write some configuration using which you can create the object and if you have this question in your mind why we are using XML when we are happy with spring boot there are two reasons why one is what if your

🔒 The full, searchable transcript is available with Pro.

🔒 Unlock Premium Features

This is a premium feature. Upgrade to unlock unlimited Q&A, transcripts, mindmaps, and translations.

🔒 Unlock Premium Features

Access to Chat is a premium feature. Upgrade now to unlock unlimited studying tools.

🔒 Unlock Premium Features

Access to Mindmap is a premium feature. Upgrade now to unlock unlimited studying tools.

🔒 Unlock Premium Features

Access to Translation is a premium feature. Upgrade now to unlock unlimited studying tools.

Get unlimited summaries, Q&A, transcripts and more with Pro

Upgrade to Pro

Suggestions

🔒 Unlock Premium Features

Access to AI Suggestions is a premium feature. Upgrade now to unlock unlimited studying tools.