我用的是SpringMVC+Spring JDBC 配置Ioc的时候,发现空指针,没有DI,报了空指针。
SpringMVC基于注解配置。然后在applicationContext中配置IOC的Bean。发现配置了没有注入进去,求解! <bean id="newsDao" class="com.zkl.dao.impl.NewsDao_Impl">
<property name="jdbcTemplate" ref="jdbcTemplate"></property>
</bean>
<bean id="newsBiz" class="com.zkl.biz.impl.NewsBiz_Impl">
<property name="newsDao" ref="newsDao"></property>
</bean>
<bean id="newsController" class="com.zkl.controller.NewsController">
<property name="newsBiz" ref="newsBiz"></property>
</bean>
SpringMVC基于注解配置。然后在applicationContext中配置IOC的Bean。发现配置了没有注入进去,求解! <bean id="newsDao" class="com.zkl.dao.impl.NewsDao_Impl">
<property name="jdbcTemplate" ref="jdbcTemplate"></property>
</bean>
<bean id="newsBiz" class="com.zkl.biz.impl.NewsBiz_Impl">
<property name="newsDao" ref="newsDao"></property>
</bean>
<bean id="newsController" class="com.zkl.controller.NewsController">
<property name="newsBiz" ref="newsBiz"></property>
</bean>
用struts的时候用xml配置,springmvc注解简单,所以用注解,跟ioc有影响?
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource" />
</bean>