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

          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學習
           
          主站蜘蛛池模板: 临沧市| 涟水县| 滦平县| 虞城县| 琼结县| 兰溪市| 融水| 东辽县| 凌海市| 崇州市| 普定县| 泰和县| 宜都市| 晴隆县| 中方县| 彰化市| 龙山县| 视频| 奈曼旗| 吉隆县| 叙永县| 汕尾市| 赣州市| 阳曲县| 特克斯县| 惠水县| 清水河县| 军事| 从江县| 清苑县| 南靖县| 新郑市| 台湾省| 太和县| 永胜县| 镇安县| 云浮市| 山西省| 灵璧县| 宿松县| 遂川县|