千山鳥飛絕 萬徑人蹤滅
          勤練內功,不斷實踐招數。爭取早日成為武林高手

          public interface IPersonService {

           public abstract void Save();

          }



          public class PersonDaoBean implements IPersonDao {

           
           public void add(){
            System.out.println("這是personDaoBean的Add()方法");
           }
          }


          public class PersonServiceBean implements IPersonService {

           private IPersonDao iPersonDao;
           
           public IPersonDao getIPersonDao() {
            return iPersonDao;
           }

           public void setIPersonDao(IPersonDao personDao) {
            iPersonDao = personDao;
           }

           public void Save(){
            iPersonDao.add();
           }
           
           
          }




          <bean id="personDaoBean" class="cn.itcast.dao.impl.PersonDaoBean"></bean>
           <bean id="personService"
            class="cn.itcast.service.impl.PersonServiceBean">
            <property name="IPersonDao" ref="personDaoBean"></property>
            </bean>
            

          public void instanceSpring() {
            ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
              "beans.xml");
            IPersonService ipersonService = (IPersonService) ctx
              .getBean("personService");
            ipersonService.Save();
            ctx.close();
            // ctx.registerShutdownHook();

           }



          輸出:這是personDaoBean的Add()方法
          posted on 2009-08-26 11:40 笑口常開、財源滾滾來! 閱讀(203) 評論(0)  編輯  收藏 所屬分類: spring學習
           
          主站蜘蛛池模板: 宝坻区| 龙州县| 阜阳市| 兴宁市| 鄂尔多斯市| 北海市| 车险| 布拖县| 汽车| 伊春市| 砀山县| 顺义区| 正宁县| 龙泉市| 汤原县| 长海县| 台东县| 沙坪坝区| 郁南县| 荥阳市| 收藏| 忻城县| 尤溪县| 湾仔区| 沙雅县| 渝中区| 瑞昌市| 肇庆市| 东城区| 阳原县| 华容县| 温宿县| 乾安县| 廉江市| 湟源县| 台东县| 无锡市| 东山县| 济阳县| 秦安县| 乡宁县|