KEMBAR78
3 Spring m3 XML Config Slides | PDF
0% found this document useful (0 votes)
30 views10 pages

3 Spring m3 XML Config Slides

The document discusses XML configuration in Spring. It describes how the applicationContext.xml file acts as a registry and how namespaces aid in configuration and validation. It also explains how beans are defined to represent classes and replace the new keyword, and how setter and constructor injection along with autowiring are used to inject dependencies.

Uploaded by

Mohammed Saad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views10 pages

3 Spring m3 XML Config Slides

The document discusses XML configuration in Spring. It describes how the applicationContext.xml file acts as a registry and how namespaces aid in configuration and validation. It also explains how beans are defined to represent classes and replace the new keyword, and how setter and constructor injection along with autowiring are used to inject dependencies.

Uploaded by

Mohammed Saad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

XML Configuration

Bryan Hansen
DIRECTOR OF SOFTWARE DEVELOPMENT
@bh5k
First Approach
Simpler
Separation of Concerns
applicationContext.xml

Name doesn’t matter


Spring Context sort of a HashMap
Can simply be a registry
XML configuration begins with this file
Namespaces aid in configuration/validation
Namespaces

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
Xml Declaration

<bean
name=“customerService”
class="com.pluralsight.service.CustomerServiceImpl"
autowire=“byName">

<property name="0"
ref="customerRepository" />

</bean>
<bean name=“customerRepository" class=
"com.pluralsight.repository.HibernateCustomerRepositoryImpl"
/>

Beans
Essentially Classes
Replaces keyword new
Define Class, use Interface
Setter Injection

Setter Injection
Constructor Injection
Used together
Better for Existing Code
Constructor Injection

Guaranteed Contract
Constructor Defined
Used together
Index based
Autowire

Spring Automatically Wires Beans


byType
byName
constructor
no
Summary applicationContext.xml
Bean Definition
Setter Injection
Constructor Injection
Auto wiring

You might also like