private DataSource datasource;
private JdbcTemplate jdbcTemplateObject; //设置注入
public void setdatasource(DataSource ds) {
this.datasource = ds;
System.out.println("xxxxxxxxxxxxxxxxx");
System.out.println(ds);
this.jdbcTemplateObject = new JdbcTemplate(datasource);
}
代码如上
排查半天发现 spring注入时,名称的大小写必须为峰驼式
改成
private DataSource datasource;
private JdbcTemplate jdbcTemplateObject; //设置注入
public void setDataSource(DataSource ds) {
this.datasource = ds;
System.out.println("xxxxxxxxxxxxxxxxx");
System.out.println(ds);
this.jdbcTemplateObject = new JdbcTemplate(datasource);
}
成功查询