如下這麼寫就沒問題
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"
p:dataSource-ref="dataSource"/>
但是如下這麼寫
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<ref name="dataSource">dataSource</ref>
</bean>
就報錯
cvc-complex-type.2.4.a: Invalid content was found starting with element 'ref'. One of '{"http://www.springframework.org/schema/beans":description, "http://www.springframework.org/schema/beans":meta, "http://www.springframework.org/schema/beans":constructor-arg, "http://www.springframework.org/schema/beans":property, "http://www.springframework.org/schema/beans":qualifier, "http://www.springframework.org/schema/beans":lookup-method, "http://www.springframework.org/schema/beans":replaced-method, WC[##other:"http://www.springframework.org/schema/beans"]}' is expected.
這倆種寫法有什麼區別?我第二種是不是寫錯了?
<property name="dataSource" ref="dataSource"></property>