0

https://www.udemy.com/spring-hibernate-tutorial/learn/v4/content

  • inversion of control

  • dependency injection

1. Spring Container

1.1 Primary functions

    • Create and manage object(Inversion of Control)

    • Inject object's dependencies(Dependency Injection)

1.2 Configuring Spring Container

    • XML configuration file(legacy, but most legacy apps still use this)

    • Java Annotations(modern)

    • Java Source Code(modern)

2. Spring Development Process--Inversion of control

  1. Configure your Spring Beans

  2. Create a Spring Container

  3. Retrieve Beans from Spring Container

Step2: Create a Spring Container

  • Spring container is generically known as ApplicationContext

  • Specialized implementations

    • ClassPathXmlApplicationContext: helps to fetch beans defined in xml. ClassPathXmlApplicationContext loads xml files from the classpath.

    • AnnotationConfigApplicationContext

    • GenericWebApplicationContext

    • others....

There are many types of Injections with Spring, the two most common are: Constructor Injection and Setter Injection.

3.1 Development process--Constructor Injection

  1. Define the dependency interface and class.

  2. Create a constructor in your class for Injections

  3. Configure the dependency injection in Spring config file

3.2 Development process--Setter Injection

  1. Create setter methods in your class for Injections

3.3 Injecting Literal Values

development process--injecting literal values

  1. Create setter methods in your class for Injections

3.4 Injecting Values from a Properties File

development process

  1. Create Properties File

  2. Load Properties File in Spring config file

  3. Reference values from Properties File

Last updated