跳转到主要内容

developerWorks 中国  >  Java technology  >

Spring 系列: Spring 框架简介

Spring AOP 和 IOC 容器入门

developerWorks

返回文章

When you print this page, select the landscape layout option.


Listing 7. The config file


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
         "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

<bean id="createCreditCard" -->define createCreditCard definition
class="springexample.creditcardaccount.CreateCreditCardAccount">
<property name="creditRatingInterface">-->inject creditRatingInterface dependency  via creditRating reference bean
<ref bean="creditRating" />
</property>
<property name="creditLinkingInterface">">-->inject creditLinkingInterface dependency  via creditLinking reference bean
<ref bean="creditLinking" />
</property>
<property name="emailInterface">">">-->inject emailInterface dependency  via email reference bean
<ref bean="email" />
/property>
</bean>

<bean id="creditLinking" class="springexample.creditlinking.CreditLinking">
<property name="url">
<value>http://localhost/creditLinkService</value>-->set url property value 
</property>
</bean>

<bean id="creditRating" class="springexample.creditrating.CreditRating">
</bean>

<bean id="email" class="springexample.email.Email">
<property name="smtpHost">
<value>localhost</value>>-->set smpHtpHost property value 
</property>
<property name="fromEmail">
<value>mycompanyadmin@mycompanyadmin.com</value>
</property>
<property name="userId">
<value>myuserid</value>
</property>
<property name="password">
<value>mypassword</value>
</property>
</bean>
</beans>

返回文章


    关于 IBM隐私条约联系 IBM