配置如下--------------------------------------------------
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')"},
minIdle: {java:"$conf.get('db.minIdle')"},
initialSize: {java:"$conf.get('db.initialSize')"},
maxActive: {java:"$conf.get('db.maxActive')"},
testWhileIdle: true,
validationQuery: {java:"$conf.get('db.validationQuery')"},
connectionInitSqls: "set names utf8mb4;",
filters: "wall"
}
},
报错信息-------------------------------------------------------
严重: Exception starting filter nutz
org.nutz.mvc.LoadingException: org.nutz.ioc.IocException: [dao, dataSource] # FAIL to create Ioc Bean name=[dataSource]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:17)
at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
at org.nutz.lang.Mirror.born(Mirror.java:990)
at org.nutz.lang.Lang.wrapThrow(Lang.java:169)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:134)
at org.nutz.mvc.ActionHandler.(ActionHandler.java:19)
at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4854)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5542)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.nutz.ioc.IocException: [dao, dataSource] # FAIL to create Ioc Bean name=[dataSource]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:149)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:209)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:75)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:209)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:235)
at org.nutz.mvc.impl.NutLoading.createIoc(NutLoading.java:391)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:102)
... 15 more
Caused by: java.lang.RuntimeException: Fail to set 'set names utf8mb4;'[ null ] by setter com.alibaba.druid.pool.DruidAbstractDataSource.'setConnectionInitSqls()' because [org.nutz.json.JsonException: !Json syntax error nearby [row:1,col:1 char 's'], reason: 'Unexpect String = set names utf8mb4;']: !Json syntax error nearby [row:1,col:1 char 's'], reason: 'Unexpect String = set names utf8mb4;'
at org.nutz.lang.Lang.makeThrow(Lang.java:104)
at org.nutz.lang.inject.InjectBySetter.inject(InjectBySetter.java:44)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
... 22 more