<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                bean.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來管理--> <bean id="accountService" class="com.itheima.service.impl.AccountServiceImpl"></bean> <bean id="accountDao" class="com.itheima.dao.impl.AccountDaoImpl" ></bean> </beans> ~~~ ***** ~~~ package com.itheima.ui; /** * @author: hcf * @qq: 46914685 * @email: 46914685@qq.com */ import com.itheima.dao.IAccountDao; import com.itheima.service.IAccountService; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; /** * 模擬一個表現層,用于調用業務層 * * 單例,多例 */ public class Client { /** * 獲取spring的IoC核心容器,并根據id獲取對象 * * ApplicationContext的三個常用實現類 * 1.ClassPathXmlApplicationContext 它可以加載類路徑下的配置文件,要求配置文件必須在類路徑下.如果不在,則加載不了 * 2.FileSystemXmlApplicationContext 可以加載磁盤任意路徑下的配置文件(必須有訪問權限) * 3.AnnotationConfigApplicationContext 用于讀取注解創建容器 * * 核心容器的兩個接口引出出的問題 * ApplicationContext: 適用場景:單例對象適用 實際開發中更多采用此方式 * 構建核心容器時,創建對象采取的策略是采用立即加載的方式.也就是說,只要一讀取完配置文件馬上就創建對象 * * BeanFactory: 適用場景:多例對象使用 * 構建核心容器時,創建對象的策略是采用延遲加載的方式.也就是說,什么時候要用該對象,什么時候才真正創建對象 * * @param args */ public static void main(String[] args) { // //1.獲取核心容器對象 ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml"); //2.根據id獲取bean對象,兩種創建方式 for (int i = 0; i < 5; i++) { IAccountService as = (IAccountService) ac.getBean("accountService"); System.out.println(as); } IAccountDao adao = ac.getBean("accountDao", IAccountDao.class); System.out.println(adao); //-----------------BeanFactory------------------- // Resource resource = new ClassPathResource("bean.xml"); // BeanFactory factory = new XmlBeanFactory(resource); // IAccountService as = factory.getBean("accountService", IAccountService.class); // System.out.println(as); } } ~~~
                  <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>

                              哎呀哎呀视频在线观看