0
Last updated
Was this helpful?
Last updated
Was this helpful?
inversion of control
dependency injection
Create and manage object(Inversion of Control)
Inject object's dependencies(Dependency Injection)
XML configuration file(legacy, but most legacy apps still use this)
Java Annotations(modern)
Java Source Code(modern)
Configure your Spring Beans
Create a Spring Container
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.
Define the dependency interface and class.
Create a constructor in your class for Injections
Configure the dependency injection in Spring config file
Create setter methods in your class for Injections
Create setter methods in your class for Injections
Create Properties File
Load Properties File in Spring config file
Reference values from Properties File
Configure the dependency injection in Spring config file
Configure the dependency injection in Spring config file