NutzCN Logo
问答 nutzboot如何配置mysql连接呢?
发布于 2530天前 作者 tuchief 3077 次浏览 复制 上一个帖子 下一个帖子
标签:

使用
@Inject
protected Dao dao;
后报如下错误信息:

org.nutz.ioc.IocException: IocBean[mainLauncher] throw Exception when creating
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:152)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:231)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:260)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:168)
	at org.nutz.boot.NbApp._run(NbApp.java:192)
	at org.nutz.boot.NbApp.run(NbApp.java:164)
	at com.deepdata.linesum.MainLauncher.main(MainLauncher.java:73)
Caused by: java.lang.RuntimeException: IocBean[mainLauncher] fail at field=[dao]
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:40)
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:67)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138)
	... 6 more
Caused by: org.nutz.ioc.IocException: IocBean[dao -> dataSource] throw Exception when creating
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:152)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:231)
	at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:60)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:64)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:231)
	at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:60)
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32)
	... 8 more
Caused by: org.nutz.lang.InvokingException: Fail to invoke [org.nutz.boot.starter.shardingjdbc.ShardingJdbcDataSourceStarter].getDataSource() by args:
 
For the reason: no such shardingjdbc configure file=shardingjdbc.yaml
	at org.nutz.lang.Invoking.invoke(Invoking.java:195)
	at org.nutz.lang.Mirror.invoke(Mirror.java:1120)
	at org.nutz.ioc.impl.ObjectMakerImpl$1.born(ObjectMakerImpl.java:80)
	at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:78)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:117)
	... 14 more
Caused by: java.lang.RuntimeException: no such shardingjdbc configure file=shardingjdbc.yaml
	at org.nutz.boot.starter.shardingjdbc.ShardingJdbcDataSourceStarter.getDataSource(ShardingJdbcDataSourceStarter.java:40)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.nutz.lang.Invoking$NullArgInvoker.invoke(Invoking.java:77)
	at org.nutz.lang.Invoking.invoke(Invoking.java:192)
	... 18 more
    @Inject
    protected Dao dao;
    @Inject
    protected Dao dao;
5 回复

用shardingjdbc 吗?? 还是普通的jdbc

@wendal 我能说我不知道该做啥配置吗?应该只要jdbc就行,不知道需要在哪里配置例如MySQLURL、用户名、密码啥的

这里有demo哦 https://github.com/nutzam/nutzboot/tree/dev/nutzboot-demo/nutzboot-demo-simple

如果你加入了shardingjdbc ,那就自动走分库分表了

是用 https://get.nutz.io 生成的吗?? 选了shardingjdbc ?

@wendal 谢谢,这回复速度好感人啊!
对的,选择了shardingjdbc了,剔除掉相关配置就不报错了!

添加回复
请先登陆
回到顶部