<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                bean1.xml文件代碼: ~~~ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> <!--把對象的創建交給spring來管理--> <!-- spring對bean的管理細節 1.創建bean的三種方式 2.bean對象的作用范圍 3.bean對象的生命周期 --> <!-- 創建Bean的三種方式--> <!-- 第一種方式創建Bean:使用默認構造函數創建 在spring的配置文件中使用bean標簽,配以id和class屬性之后,且沒有其他屬性和標簽時. 采用的就是默認構造函數創建bean對象,此時如果類中沒有默認構造函數,則對象無法創建 --> <bean id="accountService1" class="com.itheima.service.impl.AccountServiceImpl1"></bean> <!-- 第二種方式創建Bean: 使用普通工廠中的方法創建對象(使用某個類中的方法創建對象,并存入spring容器) --> <bean id="instanceFactory2" class="com.itheima.factory.InstanceFactory2"></bean> <bean id="accountService2" factory-bean="instanceFactory2" factory-method="getAccountService"></bean> <!-- 第三種方式創建Bean: 使用工廠中的靜態方法創建對象(使用某個類中的靜態方法創建對象,并存入spring容器) --> <bean id="accountService3" class="com.itheima.factory.StaticFactory3" factory-method="getAccountService"></bean> </beans> ~~~ ***** ~~~ AccountServiceImpl1.java代碼: ~~~ ~~~ package com.itheima.service.impl; import com.itheima.dao.IAccountDao; import com.itheima.dao.impl.AccountDaoImpl; import com.itheima.service.IAccountService; /** * @author: hcf * @qq: 46914685 * @email: 46914685@qq.com */ /** * 賬戶的業務層實現類 */ public class AccountServiceImpl1 implements IAccountService { //沒有構造函數,所以采用第一種方式創建bean時會出錯 // public AccountServiceImpl1(String name) { public AccountServiceImpl1() { System.out.println("對象創建了"); } public void saveAccount() { System.out.println("service中的saveAccount方法執行了!111111111"); } } ~~~ ~~~ package com.itheima.service.impl; import com.itheima.dao.IAccountDao; import com.itheima.dao.impl.AccountDaoImpl; import com.itheima.service.IAccountService; /** * @author: hcf * @qq: 46914685 * @email: 46914685@qq.com */ /** * 賬戶的業務層實現類 */ public class AccountServiceImpl1 implements IAccountService { //沒有構造函數,所以采用第一種方式創建bean時會出錯 // public AccountServiceImpl1(String name) { public AccountServiceImpl1() { System.out.println("對象創建了"); } public void saveAccount() { System.out.println("service中的saveAccount方法執行了!111111111"); } } ~~~ ***** ~~~ /** * 第一種方式創建Bean:使用默認構造函數創建 * 在spring的配置文件中使用bean標簽,配以id和class屬性之后,且沒有其他屬性和標簽時. * 采用的就是默認構造函數創建bean對象,此時如果類中沒有默認構造函數,則對象無法創建 */ @Test public void testCreateBean1(){ //1.獲取核心容器對象 ApplicationContext ac = new ClassPathXmlApplicationContext("bean1.xml"); //2.獲取bean對象 IAccountService accountService1 = ac.getBean("accountService1", IAccountService.class); accountService1.saveAccount(); } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看