写了个简单的bean,注入ioc对象时总出错,不知是为什么?
public class TestBean {
private Log log = Logs.get();
private Ioc ioc;
public void init() {
log.debug(ioc);
}
}
使用json配置加载对象:
String json = "{bean:{type:'test.TestBean',events:{create:'init'},fields:{'ioc':'refer:$ioc'}}}";
Reader reader = new StringReader(json);
Ioc ioc = new NutIoc(new JsonLoader(reader));
TestBean eventBus = ioc.get(TestBean.class, "bean");
报错信息为:
Fail to set value by field
org.nutz.castor.FailToCastObjectException: Fail to cast from <java.lang.String> to <org.nutz.ioc.Ioc> for {refer:$ioc} because:
BorningException:Fail to born 'org.nutz.ioc.Ioc'
by args: [
@(refer:$ioc)] because: No suitable Constructor or Factory Method!!
是声明的方式不正确么?