我想實例化Dao類中的數據源。我遵循Spring教程http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/jdbc.html。這是我的代碼片段:使用Spring的JdbcTemplate實例化數據源
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.*;
public class JdbcUserDao implements UserDao {
private JdbcTemplate jdbcTemplate;
public void setDataSource(DataSource dataSource){
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
但我得到一個「數據源無法解析爲類型」。 我該如何解決這個問題?
我怎麼可以導入依賴於Maven的這個圖書館? – observer 2012-03-07 09:35:00