NutzCN Logo
问答 IOC注解方式下使用有参构造方法失败
发布于 2785天前 作者 wukonggg 2386 次浏览 复制 上一个帖子 下一个帖子
标签:

到底哪里错了呢?

关键代码

@IocBean(args = {"java:$app.get('message.active.slaves.uries')"}, create = "assemble")
public class MastersAssembler {

    private Map<String, Integer> uriMap;

    public MastersAssembler(String uries) {
              // uriMap = uriesxxxxxxxx
    }

    private void assemble() {
    }

关键日志

16:51:09.252 [main] INFO  org.nutz.ioc.loader.annotation.AnnotationIocLoader #<init># - Found 12 classes in 1 base-packages!
beans = ["mastersAssembler"]
16:51:09.303 [main] INFO  org.nutz.ioc.impl.NutIoc #<init># - NutIoc init begin ...
16:51:09.306 [main] INFO  org.nutz.ioc.impl.NutIoc #<init># - ... NutIoc init complete
16:51:09.316 [main] INFO  org.nutz.ioc.impl.NutIoc #depose# - org.nutz.ioc.impl.NutIoc@1010670443 is closing. startup date [17-04-07 16:51:09.304]
16:51:09.317 [main] INFO  org.nutz.ioc.impl.NutIoc #depose# - org.nutz.ioc.impl.NutIoc@1010670443 is deposed. startup date [17-04-07 16:51:09.304]

org.nutz.ioc.IocException: [mastersAssembler] # FAIL to create Ioc Bean name=[mastersAssembler]

	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:149)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:146)
	at nutz.IocMasterTest.loadConfFromAppDotProperties(IocMasterTest.java:48)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: Fail to find Method 
MastersAssembler->assemble with params:
[]
	at org.nutz.lang.Lang.wrapThrow(Lang.java:181)
	at org.nutz.ioc.impl.ObjectMakerImpl.createTrigger(ObjectMakerImpl.java:174)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:62)
	... 33 more
Caused by: java.lang.NoSuchMethodException: Fail to find Method MastersAssembler->assemble with params:
[]
	at org.nutz.lang.Mirror.findMethod(Mirror.java:1159)
	at org.nutz.ioc.impl.ObjectMakerImpl.createTrigger(ObjectMakerImpl.java:171)
	... 34 more


Process finished with exit code -1

2 回复

assemble 要public

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