0% found this document useful (0 votes)
59 views1 page

2.3.4configure Beans (ApplicationContext - XML)

The document describes configuring Spring beans using an applicationContext.xml file. It defines beans, enables annotation-based configuration, and defines a bean for the UserAccountService class that will be autowired by name. It also mentions that a class will be created to call/inject the defined beans.

Uploaded by

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

2.3.4configure Beans (ApplicationContext - XML)

The document describes configuring Spring beans using an applicationContext.xml file. It defines beans, enables annotation-based configuration, and defines a bean for the UserAccountService class that will be autowired by name. It also mentions that a class will be created to call/inject the defined beans.

Uploaded by

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

} public void setDetails(String details) {

this.details = details;
}

2.3.4 Configure beans (applicationContext.xml)

We then create the applicationContext.xml inside the resources folder. This is for it exist on the classpath
applicationContext.xml
<beans xmlns="https://www.springframework.org/schema/beans" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xmlns:p="https://www. ←springframework.org/schema/p"
xmlns:aop="https://www.springframework.org/schema/aop" xmlns:context="https://www.
←springframework.org/schema/context"
xmlns:jee="https://www.springframework.org/schema/jee" xmlns:tx="https://www. ←springframework.org/schema/tx"
xmlns:task="https://www.springframework.org/schema/task"
xsi:schemaLocation="https://www.springframework.org/schema/aop https://www.
←springframework.org/schema/aop/spring-aop-3.2.xsd https://www.springframework. ←org/schema/beans
https://www.springframework.org/schema/beans/spring-beans-3.2. ←xsd
https://www.springframework.org/schema/context https://www.springframework. ←org/schema/context/spring-
context-3.2.xsd https://www.springframework.org/schema ←/jee https://www.springframework.org/schema/jee/spring-
jee-3.2.xsd https://www. ←springframework.org/schema/tx https://www.springframework.org/schema/tx/spring- ←tx-
3.2.xsd https://www.springframework.org/schema/task https://www. ←springframework.org/schema/task/spring-task-
3.2.xsd">

<context:annotation-config />
<!-- <bean class="org.springframework.beans.factory.annotation. ←-
AutowiredAnnotationBeanPostProcessor" /> -->

<bean id="userAccountService" autowire="byName" class="com.javacodegeeks.areyes1. ←beans.UserAccountService">


</bean>

</beans>

2.3.5 Create the class that will use (injection) the service

Create the class that will call the beans. As you can see, we called the bean by name to get the instance of that
object (cat and dog).
App.java

You might also like