首先,这个项目不是通过读取js文件获得dao的,是通过后期加入的,并且是两个数据库连接
private void setDao(UserConf userconf, Ioc ioc, SimpleDataSource source) throws ClassNotFoundException {
source.setJdbcUrl(
"jdbc:postgresql://" + userconf.getDbservername() + ":" + userconf.getDbserverport() + "/smartdc");
NutDao dao = new NutDao(source);
((Ioc2) ioc).getIocContext().save("app", "dao", new ObjectProxy(dao));
}
private void setDCMDao(UserConf userconf, Ioc ioc, SimpleDataSource source) throws Exception {
source.setJdbcUrl(
"jdbc:postgresql://" + userconf.getDbservername() + ":" + userconf.getDbserverport() + "/dcm");
NutDao dcmDao = new NutDao(source);
// dcmDao.execute(Sqls.create("CREATE DATABASE smartdc;"));
((Ioc2) ioc).getIocContext().save("app", "dcmDao", new ObjectProxy(dcmDao));
}
但是,在后面用到的时候
@IocBean
public class EntityDao extends BaseDao {
@Inject(value = "dcmDao")
Dao dcmDao;
debug
Sql sql1 = Sqls.create("SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg%' AND tablename NOT LIKE 'sql_%' ORDER BY tablename;");
sql1.setCallback(Sqls.callback.strs());
dcmDao.execute(sql1);
String[] tableNames = sql1.getObject(String[].class);
Log log = Logs.get();
log.debug(Json.toJson(tableNames));
发现所列表名均为另一个dao的表名,并非我想要的dcmDao,也就是说注入错误?请问怎么解决