NutzCN Logo
问答 有关ioc注入的问题
发布于 1853天前 作者 shichangle 1462 次浏览 复制 上一个帖子 下一个帖子
标签:

场景:
在测试类中要通过ioc获取CustomerFwBlackListServiceImpl对象,但是在CustomerFwBlackListServiceImpl对象中通过xml注入了fwBlackListBatchAddShellCommands对象,所以现在报了关于fwBlackListBatchAddShellCommands注入失败的问题,所以现在想问一下通过xml怎么注入?

代码:
@IocBean
public class CustomerFwBlackListServiceImpl implements CustomerFwBlackListService {

private static final Logger logger = LoggerFactory.getLogger(CustomerFwBlackListServiceImpl.class);

@Inject("refer:fwBlackListDao")
private FwBlackListDao fwBlackListDao;

@Inject("refer:fwBlackListServiceImpl")
private FwBlackListServiceImpl fwBlackListService;

@Inject("refer:fwBlackListBatchAddShellCommands")
private List<FwShellCommandParam> fwBlackListBatchAddShellCommands;

。。。

xml文件:




a1
fw
v1

22





这是报错日志:


org.nutz.ioc.IocException: IocBean[customerFwBlackListServiceImpl] throw Exception when creating 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 com.cloudmap.csmc.customer.protect.fw.blacklist.service.impl.CustomerServiceImplTest.setUp(CustomerServiceImplTest.java:60) 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.RunBefores.evaluate(RunBefores.java:24) 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:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Caused by: java.lang.RuntimeException: IocBean[customerFwBlackListServiceImpl] fail at field=[fwBlackListBatchAddShellCommands] at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:40) at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56) at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135) ... 25 more Caused by: org.nutz.ioc.IocException: IocBean[fwBlackListBatchAddShellCommands] For object [fwBlackListBatchAddShellCommands] - type:[] at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:218) at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24) at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32) ... 27 more Caused by: org.nutz.ioc.ObjectLoadException: Object 'fwBlackListBatchAddShellCommands' without define! at org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:166) at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:180) ... 29 more Disconnected from the target VM, address: '127.0.0.1:61008', transport: 'socket' Process finished with exit code -1
1 回复

列表不行的

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