Java EE notebook
  • Introduction
  • /web-customer-tracker
  • Web Service
  • AOP
  • Web Server2(Spring REST)
  • Security
  • Json
  • Web Server VS Application Server VS Web Containers
  • different between Servlet & JSP2
  • DI
  • 0
  • 1annotation inversion of control, bean scope
  • 2 annotation dependency injection
  • 3 annotation bean scope, java code config
  • 4 Spring MVC
  • rest web services
  • Spring-Hibernate0
  • Spring-Hibernate1
  • @ManyToMany
  • spring mvc work flow
  • Spring Security
  • JWT
  • @Autowired
  • Jersey REST Service
  • Spring Bean
Powered by GitBook
On this page
  • 1. Spring Container
  • 1.1 Primary functions
  • 1.2 Configuring Spring Container
  • 2. Spring Development Process--Inversion of control
  • e.g. XML configuration file3. Dependency Injection
  • 3.1 Development process--Constructor Injection
  • 3.2 Development process--Setter Injection
  • 3.3 Injecting Literal Values
  • 3.4 Injecting Values from a Properties File
  • development process

Was this helpful?

0

PreviousDINext1annotation inversion of control, bean scope

Last updated 5 years ago

Was this helpful?

  • 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

e.g. XML configuration file3. Dependency Injection

Configure the dependency injection in Spring config file

Configure the dependency injection in Spring config file

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