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

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] # 簡介 ![](https://box.kancloud.cn/255907935fefc28b263a3bcf0a7a9dad_1196x704.png) 1. core container a) beans與core 它們提供spring框架最基本功能,包含ioc與di b) context 上下文對象,基于beans與cores c) spel它是sprng提供的一個表達式語言 2. Data access/integration a) 數據訪問 b) 集成 3. Web a) Spring本身提供spring mvc b) 也可以與其它的web層進行集成 4. AOP AOP大部分情況下是使用動態代理來實現的。 5. Test 使用spring可以方便的進行測試 # 創建對象 ~~~ package studySpring; public class User { public User() { System.out.println("User對象空參構造方法!!!!"); } private String name; private Integer age; private Car car; public User(String name, Car car) { System.out.println("User(String name, Car car)!!"); this.name = name; this.car = car; } public User(Car car, String name) { System.out.println("User(Car car,String name)!!"); this.name = name; this.car = car; } public User(Integer name, Car car) { System.out.println("User(Integer name, Car car)!!"); this.name = name + ""; this.car = car; } public Car getCar() { return car; } public void setCar(Car car) { this.car = car; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public void init() { System.out.println("我是初始化方法!"); } public void destory() { System.out.println("我是銷毀方法!"); } @Override public String toString() { return "User [name=" + name + ", age=" + age + ", car=" + car + "]"; } } ~~~ ~~~ package studySpring; public class Car { private String name; private String color; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } @Override public String toString() { return "Car [name=" + name + ", color=" + color + "]"; } } ~~~ # 寫配置注冊對象到容器 位置任意(建議放到src下) 配置文件名任意(建議applicationContext) # 導入約束 ![](https://box.kancloud.cn/ecdd1378bb607284495ee3e442fa59b6_1294x896.png) 然后配置文件先寫 ~~~ <?xml version="1.0" encoding="UTF-8"?> <beans> </beans> ~~~ ![](https://box.kancloud.cn/8fde167983a1cf2e207af948379f7e9c_630x380.png) 然后點add ![](https://box.kancloud.cn/959b457a2d1ea1d2dc5a9d11eebc0112_1044x688.png) 確定后再點add ![](https://box.kancloud.cn/1ab53ea1a8acdc30bab364e9180ff3b3_1044x688.png) 選擇剛才添加的spring ![](https://box.kancloud.cn/178a6545bdae45386079b08e90f0cf77_1430x988.png) 點ok就行了 # 測試 在applicationContext.xml中寫 ~~~ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd "> <!-- 將User對象交給spring容器管理 --> <!-- Bean元素:使用該元素描述需要spring容器管理的對象 class屬性:被管理對象的完整類名. name屬性:給被管理的對象起個名字.獲得對象時根據該名稱獲得對象. 可以重復.可以使用特殊字符. id屬性: 與name屬性一模一樣. 名稱不可重復.不能使用特殊字符. 結論: 盡量使用name屬性. --> <bean name="user" class="studySpring.Userr" ></bean> <!-- 導入其他spring配置文件 --> <import resource="studySpring/applicationContext.xml"/> </beans> ~~~ 然后寫個類測試下 ~~~ package hello; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import bean.User; public class Demo { @Test public void fun1() { // 1.創建容器對象,因為直接在src下,就寫applicationContext.xml ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml"); // 2.向容器要User對象 User u = (User) ac.getBean("user"); // 打印User對象 System.out.println(u); } } ~~~ ApplicationContext它是BeanFactory的一個子接口,我們在使用時使用的是AppliCationContext的實現類ClassPathXmlApplicationContext
                  <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>

                              哎呀哎呀视频在线观看