你需要在
<bean id="loginManager" class="com.sunkai.managerImpl.LoginManagerImpl"> 
<property name="dataSource"> 
<ref bean="dataSource" /> 
</property> 
</bean> </beans> 
里配置
jdbcTemplate
才会得到的

解决方案 »

  1.   

    setJdbcTemplate
    public final void setJdbcTemplate(JdbcTemplate jdbcTemplate)
    Set the JdbcTemplate for this DAO explicitly, as an alternative to specifying a DataSource. 
      

  2.   

    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource">
    <ref bean="dataSource" />
        </property>
    </bean>

    <bean id="loginManager" class="com.sunkai.managerImpl.LoginManagerImpl">
        <property name="jdbcTemplate">
    <ref bean="jdbcTemplate" />
        </property>
    </bean>
    改成这样还是无效呀?
      

  3.   

    重新编译一下,这里set了再怎么说也不会是找不到jdbctemplate了
      

  4.   

    重新编译,重新部属过了,还是NULL,疯了,我看别人的例子都是这么搞定的呀
      

  5.   

    好像是没有注入进去,我取dataSource也没有取到,这是怎么回事
      

  6.   

    应该会注入,你debug查看下变量
    或者datasource配置不对?
    将bean改为local看看
      

  7.   

    我现在已经确定了是没有注入成功,是不是我在WEB.XML配置有问题,所以在启动时没有注入啊?web.xml配置入下
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/applicationContext.xml
        </param-value>
    </context-param>

    <listener>   
         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>   
     </listener>