NutzCN Logo
问答 关于文件管理自定义SQL在ioc/dao.js配置
发布于 3166天前 作者 qq_7e34a32e 2160 次浏览 复制 上一个帖子 下一个帖子
标签:

var ioc = {
conf : {
type : "org.nutz.ioc.impl.PropertiesProxy",
fields : {
paths : ["cfg/db.properties"]
}
},
dataSource : {
type : "com.alibaba.druid.pool.DruidDataSource",
events : {
create : "init",
depose : 'close'
},
fields : {
url : {java:"$conf.get('db.url')"},
username : {java:"$conf.get('db.username')"},
password : {java:"$conf.get('db.password')"},
testWhileIdle : true,
validationQuery : {java:"$conf.get('db.validationQuery')"},
maxActive : {java:"$conf.get('db.maxActive')"}
}
},
sql : {
type : "org.nutz.dao.impl.FileSqlManager",
fields : {
paths : ["sql/*.sqls"]
}
},
dao : {
type : "org.nutz.dao.impl.NutDao",
args : [{refer:"dataSource"},{refer:"sql"}]
}

};
untitled1_png

9 回复
paths : ["sql/*.sqls"]

改成

paths : ["config/sql/"]

错了了,不需要config/

还是启动不了,错误信息:
Caused by: org.nutz.ioc.IocException: Fail to born 'org.nutz.dao.impl.FileSqlManager'
by args: [] becasue:
java.lang.IllegalArgumentException: wrong number of arguments FAIL to create Ioc Bean name=[sql]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:147)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:204)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:75)
... 26 more
Caused by: org.nutz.lang.born.BorningException: Fail to born 'org.nutz.dao.impl.FileSqlManager'
by args: [] becasue:
java.lang.IllegalArgumentException: wrong number of arguments
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:23)
at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:67)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:114)
... 29 more

@wendal(wendal) 还是启动不了,错误信息:
Caused by: org.nutz.ioc.IocException: Fail to born 'org.nutz.dao.impl.FileSqlManager'
by args: [] becasue:
java.lang.IllegalArgumentException: wrong number of arguments FAIL to create Ioc Bean name=[sql]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:147)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:204)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:75)
... 26 more
Caused by: org.nutz.lang.born.BorningException: Fail to born 'org.nutz.dao.impl.FileSqlManager'
by args: [] becasue:
java.lang.IllegalArgumentException: wrong number of arguments
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:23)
at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:67)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:114)
... 29 more

看org.nutz.dao.impl.FileSqlManager的构造方法

@wendal(wendal) 读取sql文件的那段json,没问题,好像是
dao : {
type : "org.nutz.dao.impl.NutDao",
args : [{refer:"dataSource"},{refer:"sql"}]
}
后面引入refer:"sql",

看org.nutz.dao.impl.FileSqlManager的构造方法

@wendal(wendal) [哭泣] 看不出问题,

sql : {
type : "org.nutz.dao.impl.FileSqlManager",
args : ["sql/"]
},
添加回复
请先登陆
回到顶部