我正在尝试自动连接 JDBC 模板,但出现空指针异常(模板为空)。可能是什么问题呢?
@Autowired
template JdbcTemplate;
这是我的应用程序上下文 xml:
<bean ..>
<mvc:annotation-driven />
<context:component-scan base-package="igate.dto" />
<context:component-scan base-package="igate.dao" />
<context:component-scan base-package="igate.service" />
<context:component-scan base-package="igate.controller" />
<context:component-scan base-package="igate.logs" />
<context:component-scan base-package="igate.testcases" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"/>
<property name="suffix" value=".jsp" />
</bean>
<bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@172.21.17.5:1521:oraten" />
<property name="username" value="lab01trg21" />
<property name="password" value="lab01oracle" />
</bean>
<bean id="template" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="ds"/>
</bean>
</beans>