From the course: Learning Spring 6 with Spring Boot 3
Introduction to Spring - Spring Tutorial
From the course: Learning Spring 6 with Spring Boot 3
Introduction to Spring
- [Instructor] The Spring Framework is by far the most popular framework for the JVM today, and for good reason. The simplicity of use, the power for developers, and the community are a big part of the reason for its success. The Spring Framework is based on some key components, as well as design patterns. At its core, it is a framework for providing comprehensive infrastructural support for developing JVM based applications. There are many built-in abstractions for just about every situation you may encounter in the enterprise world. Essentially, Spring provides the plumbing, as well as the scaffolding, so you can focus primarily on your business logic. It does this by relying on OOP best practices and using those to define the abstractions in the framework. All of this is based on the dry principles or don't repeat yourself. Much of the plumbing and abstraction is to remove the repeated code of many enterprise and internet software routines. Before we get much deeper into the framework, I want to level set on some of the definitions that we will use and how they apply to the Spring world since their use can be confusing to some people because they're disambiguous with other uses within Java. A POJO or Plain Old Java Object is a Java class in the purest sense. It contains both attributes and methods for working with the class. Java Beans from the EJB world are objects with only gitters and setters for the attributes. Spring beans however, are POJOs configured in the application context. We will explain the application context later on in the course, but this definition of Spring Bean and POJO verse a Java Bean is a major point of confusion. So I want to make this very, very clear. DTOs or data transfer objects are nothing more than Java Beans that are used to move state between logical layers of code. So let's talk a little bit more about what makes Spring simple to use. One cannot give enough credit to the Spring source documentation. One of the biggest complaints I have had in my career about using different forms of technology is that the developer documentation is not clear, not concise or not complete, but that isn't the case with Spring. Use cases, examples, and general patterns are clearly documented on their website. The framework builds its constructs off of common patterns, things like the template pattern that they use. This allows for an easier learning curve when picking up new pieces of their stack. This of course, speeds up adoption of the framework to say the least. One of the early complaints of Spring was configuration was done via XML. The use of XML is no longer required and hasn't been for a while, but to configuration of the container itself is still required. Most of Spring is configured via annotation based component scanning or the use of Java itself. When you add Spring Boot to the mix, you get auto configuration as well, making it even easier. Inversion of control is a primary focus on how the framework itself works. Now, we just discussed briefly configuration of a Spring application. What we are actually configuring is the inversion of control container, which is the most central component of a running Spring application. Now, we're going to discuss IoC in some depth, but for now, just understand that this is what configuration is building. Inversion of control is one of those OOP patterns that is part of the framework, and Spring leverages it to its core. Inversion of control provides the mechanism of dependency injection, allowing a shift in object creation and management from traditional applications. The application context wraps the BeanFactory. That BeanFactory ultimately is the inversion of control container, which serves beans to the runtime of the application. As briefly mentioned, Spring Boot provides auto configuration of the BeanFactory based on the presence or absence of classes among other conditionals. This greatly improves the speed of application development. Now, we are going to go into a lot of depth on this, but for a real deep dive into how Spring works, I suggest you check out my course, Spring Framework in Depth here on the LinkedIn Learning Library.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.