Nuta连接池配置问题
var ioc = { dataSource: { //type: "com.mchange.v2.c3p0.ComboPooledDataSource", type : "com.alibaba.druid.pool.DruidDataSource", events : { depose : 'close' }, fields: { driverClass: 'com.mysql.jdbc.Driver', jdbcUrl: 'jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8', user: 'root', password: 'root', testWhileIdle:true } }, dao : { type : 'org.nutz.dao.impl.NutDao', args : [{refer:'dataSource'}] } };这样写之后报错
java.lang.RuntimeException: Fail to eval Injector for field: 'user' at org.nutz.lang.Lang.wrapThrow(Lang.java:121) at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:88) at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:182) at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24) at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:66) at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:182) at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24) at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23) at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56) at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:95) at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:182) at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24) at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23) at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56) at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:95) at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:182) at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:72) 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:36) at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:66) at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:30) at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:97) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1760) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.RuntimeException: java.lang.NoSuchFieldException: Can NOT find field [user] in class [com.alibaba.druid.pool.DruidDataSource] and it's parents classes at org.nutz.lang.Lang.wrapThrow(Lang.java:138) at org.nutz.lang.Mirror.getInjecting(Mirror.java:950) at org.nutz.ioc.weaver.FieldInjector.create(FieldInjector.java:13) at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:85) ... 35 more Caused by: java.lang.NoSuchFieldException: Can NOT find field [user] in class [com.alibaba.druid.pool.DruidDataSource] and it's parents classes at org.nutz.lang.Mirror.getField(Mirror.java:435) at org.nutz.lang.Mirror.getInjecting(Mirror.java:941) ... 37 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
名字写错了吧
从异常里很容易看出:
是字段名错了,应该是
即,是 "username" 而不是 "user"
更多关于 Nutz 的与各个连接池的用法,请参看 http://nutzam.com/core/appendix/create_datasource.html
jar都不缺,原因是这个: c3p0的写法:<property name="user" value="${jdbc.username}" /> druid连接池:<property name="username" value="${jdbc.username}"/>
用了温少的连接池,是不是没有把jar包加进去啊