很明显JdbcTemplate没有被事例化
<beans>
<bean id= "dataSource "
class= "org.apache.commons.dbcp.BasicDataSource ">
<property name= "driverClassName ">
<value> net.sourceforge.jtds.jdbc.Driver </value>
</property>
<property name= "url ">
<value> jdbc:jtds:sqlserver://127.0.0.1:1433/test </value>
</property>
<property name= "username ">
<value> sa </value>
</property>
<property name= "password ">
<value> </value>
</property>
</bean>
<bean id= "jdbcTemplate " class= "org.springframework.jdbc.core.JdbcTemplate ">
<constructor-arg>
<ref bean= "dataSource " />
</constructor-arg>
</bean>
<bean id= "dao " class= "bean.Dao " singleton= "false ">
<property name= "jdbcTemplate ">
<ref bean= "jdbcTemplate " />
</property>
</bean>
</beans>
public class Dao implements DaoImpl{
private JdbcTemplate jdbcTemplate;
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
public void findAll() {
String sql = "select * from user ";