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

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                案例代碼:https://gitee.com/flymini/codes01/tree/master/spring_/com-learn-spring02 **** 下面演示如何在 IoC 容器里面對屬性賦值。 <br/> **1. 創建一個實體類** ```java @Data public class Complex { /** 屬性類型為 基本數據類型或字符串,或包裝類型 */ private double doubleVar; private String stringVar; private String cataVar; private Long longVar; /** 屬性類型為接口 */ private UserDao userDao; private UserDao userDaoTwo; /** 屬性類型為一個實體類 */ private Student student; /** 屬性類型為集合類型 */ private String stringArray[]; private List<String> stringList; private List<Double> doubleList; private Set<String> stringSet; private Map<String, Object> objectMap; } ``` **2. 在 IoC 容器中對實體類的屬性賦值** *`resources/ApplicationContentext.xml`* ```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" xmlns:utils="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd"> <bean id="complexBean" class="com.learn.spring02.pojo.Complex"> <property name="doubleVar" value="3.14159"/> <property name="stringVar" value="張三,你好!"/> <property name="cataVar"> <!-- 包含特殊字符的字符串寫到<![CDATA[val]]>,如<、>等 --> <value><![CDATA[<<南京>>]]></value> </property> <property name="longVar" value="1000"/> <property name="userDao" ref="userDaoImpl"/> <property name="userDaoTwo"> <bean id="userDaoTwo" class="com.learn.spring02.dao.impl.UserDaoImpl"/> </property> <property name="student" ref="studentBean"/> <property name="stringArray"> <array> <value>中國</value> <value>美國</value> <value>俄羅斯</value> </array> </property> <property name="stringList"> <list> <value>中國</value> <value>美國</value> <value>俄羅斯</value> </list> </property> <property name="doubleList" ref="moneyList"/> <property name="stringSet"> <set> <value>中國</value> <value>美國</value> <value>俄羅斯</value> </set> </property> <property name="objectMap"> <map> <entry key="zhongguo" value="中國"></entry> <entry key="student" value-ref="studentBean"></entry> </map> </property> </bean> <bean id="userDaoImpl" class="com.learn.spring02.dao.impl.UserDaoImpl"/> <bean id="studentBean" class="com.learn.spring02.pojo.Student"> <property name="studentName" value="王五"/> <property name="studentAge" value="25"/> </bean> <!-- 也有對應的 set、map --> <utils:list id="moneyList"> <value>79.45</value> <value>80.05</value> </utils:list> </beans> ``` **3. 測試** ```java public class ComplexTest { /** * 獲取 IoC 容器 */ private final ApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContentext.xml"); @Test public void testComplex() { Complex complex = context.getBean("complexBean", Complex.class); //3.14159 System.out.println(complex.getDoubleVar()); //張三,你好! System.out.println(complex.getStringVar()); //<<南京>> System.out.println(complex.getCataVar()); //1000 System.out.println(complex.getLongVar()); //UserDaoImpl.print() complex.getUserDao().print(); //UserDaoImpl.print() complex.getUserDaoTwo().print(); //Student(studentName=王五, studentAge=25) System.out.println(complex.getStudent()); //[中國, 美國, 俄羅斯] System.out.println(Arrays.asList(complex.getStringArray())); //[中國, 美國, 俄羅斯] System.out.println(complex.getStringList()); //[79.45, 80.05] System.out.println(complex.getDoubleList()); //[中國, 美國, 俄羅斯] System.out.println(complex.getStringSet()); //{zhongguo=中國, student=Student(studentName=王五, studentAge=25)} System.out.println(complex.getObjectMap()); } } ```
                  <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>

                              哎呀哎呀视频在线观看