报异常:
org.nutz.ioc.IocException: [testModule, dao, dataSource, config] # For object [config] - type:[]
t org.nutz.ioc.impl.NutIoc.get(NutIoc.java:218)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
at org.nutz.ioc.java.IocObjectNode.getValue(IocObjectNode.java:19)
at org.nutz.ioc.java.ChainNode.eval(ChainNode.java:24)
at org.nutz.ioc.java.ChainNode.eval(ChainNode.java:19)
at org.nutz.ioc.val.JavaValue.get(JavaValue.java:69)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:60)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:116)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:198)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: org.nutz.ioc.ObjectLoadException: Object 'config' without define!
at org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:174)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:180)
... 48 more
resources 目录下
config.properties 文件
db-local-driver=com.mysql.jdbc.Driver
db-local-url=jdbc:mysql://localhost:3306/mynutz
db-local-username=mynutz
db-local-password=mynutz
db-local-validationQuery=select version();
ioc 目录下
config_local.js 文件
var config = {
dataSource : {
type : "com.alibaba.druid.pool.DruidDataSource",
events : {
depose : 'close'
},
fields : {
driverClassName : {
java : "$config.get('db-local-driver')"
},
url : {
java : "$config.get('db-local-url')"
},
username : {
java : "$config.get('db-local-username')"
},
password : {
java : "$config.get('db-local-password')"
},
filters : "stat,log4j",
testOnBorrow : false
}
},
dao : {
type : "org.nutz.dao.impl.NutDao",
fields : {
dataSource : {
refer : 'dataSource'
}
}
}
};
大概意思是找不到 找不到 config.properties
如果 config_local.js 内容改为
var config = {
dataSource : {
type : "com.alibaba.druid.pool.DruidDataSource",
events : {
depose : 'close'
},
fields : {
driverClassName : "com.mysql.jdbc.Driver",
url : "jdbc:mysql://localhost:3306/mynutz",
username : "mynutz",
password : "mynutz",
validationQuery : "select version()"
}
},
dao : {
type : "org.nutz.dao.impl.NutDao",
fields : {
dataSource : {
refer : 'dataSource'
}
}
}
};
就没有问题