0
      <?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
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

        <bean id="SampleWorld" class="com.spring.collections"

1. 这就是我得到元素类型“bean”必须后跟属性规范“>”或“/>”的点。

            <property name="list">
                <list>
                    <value> 1 </value>
                </list>
                <ref = employee " />
            </property>

            <property name="set">
                <set>
                    <value> 21</value>
                </set>
                <ref = employee " />
            </property>

            <property name="properties">
                <properties>
                    <value> 21</value>
                </properties>
                <ref = employee " />
            </property>
            <property name="map">
                <map>
                    <entry key="1" value="value1" />
                    <entry key="2" value-ref="employee" />
                </map>
            </property>
        </bean>

2. 这是另一个注入id和员工依赖的依赖bean类。

        <bean id="employee" class="com.spring.collections"


            <property name="id" value="2312" />
            <property name="employeeName" value="SpringHero" />
        </bean>
    </beans>
4

1 回答 1

3

您必须先完成元素的开始标记,然后才能拥有任何嵌套内容(其他元素或文本)。在 XML 中,这很好:

<x>
  <y />
</x>

但这不是:

<x
  <y />
</x>

这不是特定于 Spring 或特定于 Java 的——你现在得到的是无效的 XML。唯一可以在开始标签中的是属性。

于 2014-09-10T02:54:39.027 回答