Spring Core

XML

IOC Container

Dependency Inversion principle

provides loose coupling

by depending on abstraction

by using dependency injection

by setting configuration

Annotation

ApplicationContext

ClassPathXmlApplicationContext()

package_path/filename.xml

ApplicationContext

AnnotationConfigApplicationContext()

ConfigBean.class

(Interface) Context.getBean("id")

(Interface) context.getBean(Interface.class)

config.xml

< beans>

<bean>

xml definition

attribute

class

fully qualified classname

id

<properties>

setter injection

<constructor-arg>

attribute

name

constructor injection

attribute

value

index

type

value

< context:component-scan>

attribute

base-package

Annotations

@Component

attached: Class definition

purpose: IOC Component

@Primary

for multiple implementations

@Autowired

purpose: injection point

attached: variables declaration

@Qualifier

for multiple implementations

@Configuration

purpose: specify Bean Config class

attached: class definition

@Bean

purpose: specify an instance to return for DI

@ComponentScan

purpose: scan for an implementation for DI

attached: method definition

attached: class definition (Bean Config)

Youtube Telusko: Spring Framework Tutorial | Full Course