千山鳥(niǎo)飛絕 萬(wàn)徑人蹤滅
          勤練內(nèi)功,不斷實(shí)踐招數(shù)。爭(zhēng)取早日成為武林高手

          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()方法
           
          主站蜘蛛池模板: 沁源县| 弋阳县| 三明市| 太原市| 寿光市| SHOW| 阳春市| 东源县| 大埔区| 南乐县| 浪卡子县| 耒阳市| 丹东市| 阜新市| 大石桥市| 万州区| 宜兰市| 林西县| 邯郸市| 平塘县| 绵竹市| 冷水江市| 桃源县| 平乐县| 长泰县| 准格尔旗| 水富县| 莱州市| 陵水| 沾化县| 酒泉市| 涞水县| 黄冈市| 凤阳县| 恩平市| 镇康县| 泽库县| 左权县| 普兰店市| 大埔县| 湛江市|