- Core: Provices the fundamental parts of the framework.
- Bean: Provides BeanFactory.
- Context: It is a medium to access any objects defined and configured.
- SpEL: Provides a powerful expression language.
- Bean or Model or POJO Class
- Xml file
- Demo Class
- Load jar files
- Run
- Create a forlder in the project (example: "lib")
- Go to the below link and download "spring-framework-5.1.9.RELEASE-dist.zip" https://repo.spring.io/release/org/springframework/spring/5.1.9.RELEASE/
- Unzip and copy below jars to "lib" folder
- spring-aop-5.1.9.RELEASE.jar
- spring-beans-5.1.9.RELEASE.jar
- spring-context-5.1.9.RELEASE.jar
- spring-core-5.1.9.RELEASE.jar
- spring-expression-5.1.9.RELEASE.jar
- Go to any of the below link and download "spring tool suite 4" https://spring.io/tools https://download.springsource.com/release/STS4/4.3.2.RELEASE/dist/e4.12/spring-tool-suite-4-4.3.2.RELEASE-e4.12.0-win32.win32.x86_64.zip
- Unzip and copy below jars to "lib" folder
- org.apache.commons.logging_1.2.0.v20180409-1502.jar
- Now follow the below steps
- right-click the project name
- Build Path
- Configure Build Path
- select Libraries Tab
- select Classpath
- Click Add External JARS
- Browse to the lib folder and add all the jars
- You don"t create objects.
- Objects shall be configured in an XML file by the developer.
- Spring Container -> Responsible to construct the Java Objects by parsing XML file.
- ApplicationContext will create the object for us eventhough we don"t request.
- Beanfactory will create the object for us only when we are going to request for it(by calling the getbean method).
- Construction of the objects
- Managing the entire lifecycle of the objects is not a headache of the developer now
- Wiring them together (there might be dependencies which we can link up)
- Configuration (means key-value pair, just need to configure the object in the xml file)
- Constructor Injection
- Setter Injection
(so, we need to mention the data which these attributes will store in an xml file. Benifits of having such an object is that our XML files are not part of source code, so we can configure or manipulate the values at any time and our object will be constructed accordingly.)
BeanFactory is nothing but a spring container which shall read or which shall parse XML file and construct the objects. Here, we don"t construct the objects now.
So objects are constructed by the spring container and we are just obtaining the reference to the object.
ApplicationContext is also one of the core container in the spring framework which is used to do the inversion of control. It"s basically an implementaion of the bean package. ApplicationContext is basically built on top of bean pattern.
So, spring inversion of control says that you don"t create objects, objects will be constructed by the spring core container.
Followed 2 types of dependency injection here.