2.3.4configure Beans (ApplicationContext - XML)
2.3.4configure Beans (ApplicationContext - XML)
this.details = details;
}
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" /> -->
</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