spring配置mysql的时候有个奇怪的问题

如下这么写就没问题


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

ref是属性,不是子元素。

图片说明

哪有流行流行,先保证不出错