Skip to content

salekin01/Java-Spring-Core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Spring Core skeleton

Spring Core Container

  • 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.

Start Coding in 5 Simple Steps

  • Bean or Model or POJO Class
    • Xml file
      • Demo Class
        • Load jar files
          • Run

Project Sturcture

How to add external libraries

  • 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

    Understanding Spring Core | IOC (Inversion of Control)

    • You don"t create objects.
    • Objects shall be configured in an XML file by the developer.
    • (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.)

    • Spring Container -> Responsible to construct the Java Objects by parsing XML file.

    Understanding Spring Core | BeanFactory & ApplicationContext

    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.

    Differences:
    • 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).

    So, spring inversion of control says that you don"t create objects, objects will be constructed by the spring core container.

    IOC-Features

    1. Construction of the objects
    2. Managing the entire lifecycle of the objects is not a headache of the developer now
    3. Wiring them together (there might be dependencies which we can link up)
    4. Configuration (means key-value pair, just need to configure the object in the xml file)

    Dependency Injection

    Followed 2 types of dependency injection here.

    • Constructor Injection
    • Setter Injection

About

Java Spring Core skeleton

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages