NutzCN Logo
问答 org.nutz.ioc.IocException none ioc bean
发布于 2603天前 作者 qq_1a0ba638 1910 次浏览 复制 上一个帖子 下一个帖子
标签:
org.nutz.ioc.IocException: [indedxController, class:com.yc.service.IndexService] # none ioc bean match class=com.yc.service.IndexService
	at org.nutz.ioc.impl.NutIoc.getByType(NutIoc.java:382)
	at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:30)
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
	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.processor.ModuleProcessor.process(ModuleProcessor.java:116)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)

总是报这个错误 但是我IndexService的实现类已经加了IocBean了

@IocBean
@Ok("json")
public class IndedxController {

    @Inject
    private IndexService indexService;

    @Inject
    protected Dao dao;

    @At
    public void showUser() {
        //indexService.showUsers();
        System.out.println("sadasd");
    }

}
@IocBean
public class IndexServiceImpl implements IndexService {

    @Inject
    private IndexDao indexDao;

    public void showUsers() {
        indexDao.showUsers();
    }

}
10 回复
@IocBean(name="indexService")
public class IndexServiceImpl implements IndexService {
}

另外, 是不是IndexService 有几个,重名了,导致import错了?

@IocBean(name="indexService")
public class IndexServiceImpl implements IndexService {
}

改成这样还是会报这个错

我建的工程类只有IndexController IndexService IndexServiceImpl IndexDao IndexDaoImpl 以及MainModule

@IocBy贴来看看,感觉是没有涵盖service所在的package

@IocBy(type=ComboIocProvider.class, args = { "*js", "ioc/", "*anno", "com.yc", "*tx" })
@Modules(scanPackage = true)
public class MainMoudle {
}

@wendal

启动日志贴一下

2017-11-6 16:57:4.198 INFO [RMI TCP Connection(3)-127.0.0.1] NutFilter[nutz] starting ...
2017-11-6 16:57:4.213 INFO [RMI TCP Connection(3)-127.0.0.1] [loc=file:/D:/Idea%20Workspaces/NutzDemo/target/NutzDemo/WEB-INF/lib/nutz-1.r.56.jar]not exist
2017-11-6 16:57:4.220 DEBUG [RMI TCP Connection(3)-127.0.0.1] Locations for Scans:
[JarResourceLocation [jarPath=D:\Program Files\Apache Software Foundation\apache-tomcat-7.0.81\bin\bootstrap.jar], JarResourceLocation [jarPath=D:\Program Files\Apache Software Foundation\apache-tomcat-7.0.81\bin\tomcat-juli.jar], FileSystemResourceLocation [root=D:\Program Files\Apache Software Foundation\apache-tomcat-7.0.81\bin], ErrorResourceLocation [loc=file:/D:/Idea%20Workspaces/NutzDemo/target/NutzDemo/WEB-INF/lib/nutz-1.r.56.jar]]
2017-11-6 16:57:4.424 DEBUG [RMI TCP Connection(3)-127.0.0.1] Locations for Scans:
[JarResourceLocation [jarPath=D:\Idea Workspaces\NutzDemo\target\NutzDemo\WEB-INF\lib\druid-1.0.18.jar], JarResourceLocation [jarPath=D:\Idea Workspaces\NutzDemo\target\NutzDemo\WEB-INF\lib\nutz-1.r.56.jar], JarResourceLocation [jarPath=D:\Idea Workspaces\NutzDemo\target\NutzDemo\WEB-INF\lib\mysql-connector-java-5.1.38.jar], JarResourceLocation [jarPath=D:\Program Files\Apache Software Foundation\apache-tomcat-7.0.81\bin\bootstrap.jar], JarResourceLocation [jarPath=D:\Program Files\Apache Software Foundation\apache-tomcat-7.0.81\bin\tomcat-juli.jar], JarResourceLocation [jarPath=D:\Idea Workspaces\NutzDemo\target\NutzDemo\WEB-INF\lib\jstl-1.2.jar], FileSystemResourceLocation [root=D:\Program Files\Apache Software Foundation\apache-tomcat-7.0.81\bin], ErrorResourceLocation [loc=file:/D:/Idea%20Workspaces/NutzDemo/target/NutzDemo/WEB-INF/lib/nutz-1.r.56.jar], FileSystemResourceLocation [root=D:\Idea Workspaces\NutzDemo\target\NutzDemo\WEB-INF\classes]]
2017-11-6 16:57:4.429 DEBUG [RMI TCP Connection(3)-127.0.0.1] MainModule: <com.yc.MainMoudle>
2017-11-6 16:57:4.438 DEBUG [RMI TCP Connection(3)-127.0.0.1] Loading by class org.nutz.mvc.impl.NutLoading
2017-11-6 16:57:4.440 INFO [RMI TCP Connection(3)-127.0.0.1] Nutz Version : 1.r.56 
2017-11-6 16:57:4.440 INFO [RMI TCP Connection(3)-127.0.0.1] Nutz.Mvc[nutz] is initializing ...
2017-11-6 16:57:4.441 DEBUG [RMI TCP Connection(3)-127.0.0.1] Web Container Information:
2017-11-6 16:57:4.443 DEBUG [RMI TCP Connection(3)-127.0.0.1]  - Default Charset : GBK
2017-11-6 16:57:4.443 DEBUG [RMI TCP Connection(3)-127.0.0.1]  - Current . path  : D:\Program Files\Apache Software Foundation\apache-tomcat-7.0.81\bin\.
2017-11-6 16:57:4.443 DEBUG [RMI TCP Connection(3)-127.0.0.1]  - Java Version    : 1.8.0_151
2017-11-6 16:57:4.444 DEBUG [RMI TCP Connection(3)-127.0.0.1]  - File separator  : \
2017-11-6 16:57:4.444 DEBUG [RMI TCP Connection(3)-127.0.0.1]  - Timezone        : Asia/Shanghai
2017-11-6 16:57:4.444 DEBUG [RMI TCP Connection(3)-127.0.0.1]  - OS              : Windows 10 amd64
2017-11-6 16:57:4.444 DEBUG [RMI TCP Connection(3)-127.0.0.1]  - ServerInfo      : Apache Tomcat/7.0.81
2017-11-6 16:57:4.444 DEBUG [RMI TCP Connection(3)-127.0.0.1]  - Servlet API     : 3.0
2017-11-6 16:57:4.444 DEBUG [RMI TCP Connection(3)-127.0.0.1]  - ContextPath     : /NutzDemo
2017-11-6 16:57:4.445 DEBUG [RMI TCP Connection(3)-127.0.0.1]  - context.tempdir : C:\Users\rrr\.IntelliJIdea2017.2\system\tomcat\Unnamed_NutzDemo_5\work\Catalina\localhost\NutzDemo
2017-11-6 16:57:4.446 DEBUG [RMI TCP Connection(3)-127.0.0.1] MainModule: <com.yc.MainMoudle>
2017-11-6 16:57:4.446 DEBUG [RMI TCP Connection(3)-127.0.0.1] >> app.root = D:/Idea Workspaces/NutzDemo/target/NutzDemo
2017-11-6 16:57:4.534 DEBUG [RMI TCP Connection(3)-127.0.0.1] Using 94 castor for Castors
2017-11-6 16:57:4.537 DEBUG [RMI TCP Connection(3)-127.0.0.1] @IocBy(type=org.nutz.mvc.ioc.provider.ComboIocProvider, args=["*js", "ioc/", "*anno", "com.yc", "*tx"],init=[])
2017-11-6 16:57:4.568 DEBUG [RMI TCP Connection(3)-127.0.0.1] Found 1 resource by src( ioc/ ) , regex( ^(.+[.])(js|json)$ )
2017-11-6 16:57:4.568 DEBUG [RMI TCP Connection(3)-127.0.0.1] loading ioc js config from [dao.js]
2017-11-6 16:57:4.577 DEBUG [RMI TCP Connection(3)-127.0.0.1] Loaded 4 bean define from path=[ioc/] --> [conf, dao, dataSource, sql]
2017-11-6 16:57:4.582 DEBUG [RMI TCP Connection(3)-127.0.0.1] Found 8 resource by src( com/yc/ ) , regex( ^.+[.]class$ )
2017-11-6 16:57:4.590 INFO [RMI TCP Connection(3)-127.0.0.1] Resource can't map to Class, Resource service/Impl/IndexServiceImpl.class
2017-11-6 16:57:4.601 DEBUG [RMI TCP Connection(3)-127.0.0.1] Found : class com.yc.controller.IndexController
2017-11-6 16:57:4.609 DEBUG [RMI TCP Connection(3)-127.0.0.1] Found : class com.yc.dao.impl.IndexDaoImpl
2017-11-6 16:57:4.615 INFO [RMI TCP Connection(3)-127.0.0.1] Found 2 classes in 1 base-packages!
beans = ["indexController", "indexDaoImpl"]
2017-11-6 16:57:4.617 DEBUG [RMI TCP Connection(3)-127.0.0.1] Loaded 5 bean define from reader --
[txREPEATABLE_READ, txSERIALIZABLE, txNONE, txREAD_UNCOMMITTED, txREAD_COMMITTED]
2017-11-6 16:57:4.620 INFO [RMI TCP Connection(3)-127.0.0.1] NutIoc init begin ...
2017-11-6 16:57:4.623 INFO [RMI TCP Connection(3)-127.0.0.1] ... NutIoc init complete
2017-11-6 16:57:4.624 DEBUG [RMI TCP Connection(3)-127.0.0.1] MainModule: <com.yc.MainMoudle>
2017-11-6 16:57:4.629 INFO [RMI TCP Connection(3)-127.0.0.1] Build URL mapping by org.nutz.mvc.impl.UrlMappingImpl ...
2017-11-6 16:57:4.635 DEBUG [RMI TCP Connection(3)-127.0.0.1] @Views(DefaultViewMaker.class)
2017-11-6 16:57:4.650 DEBUG [RMI TCP Connection(3)-127.0.0.1] @ChainBy(org.nutz.mvc.impl.NutActionChainMaker)
2017-11-6 16:57:4.679 DEBUG [RMI TCP Connection(3)-127.0.0.1] module class location 'file:/D:/Idea%20Workspaces/NutzDemo/target/NutzDemo/WEB-INF/classes/'
2017-11-6 16:57:4.679 INFO [RMI TCP Connection(3)-127.0.0.1] [loc=D:\Idea%20Workspaces\NutzDemo\target\NutzDemo\WEB-INF\classes]not exist
2017-11-6 16:57:4.679 DEBUG [RMI TCP Connection(3)-127.0.0.1]  > scan 'com.yc'
2017-11-6 16:57:4.686 DEBUG [RMI TCP Connection(3)-127.0.0.1] Found 8 resource by src( com/yc/ ) , regex( ^.+[.]class$ )
2017-11-6 16:57:4.689 INFO [RMI TCP Connection(3)-127.0.0.1] Resource can't map to Class, Resource service/Impl/IndexServiceImpl.class
2017-11-6 16:57:4.689 DEBUG [RMI TCP Connection(3)-127.0.0.1]    >> add 'com.yc.controller.IndexController'
2017-11-6 16:57:4.702 INFO [RMI TCP Connection(3)-127.0.0.1] Optional processor class not found, disabled : org.nutz.integration.shiro.NutShiroProcessor
2017-11-6 16:57:4.722 INFO [RMI TCP Connection(3)-127.0.0.1] Optional processor class not found, disabled : org.nutz.plugins.validation.ValidationProcessor
2017-11-6 16:57:4.732 DEBUG [RMI TCP Connection(3)-127.0.0.1]    '/showuser'                 >> IndexController.showUser(...)  : void       | @Ok(json ) @Fail(null ) | by 0 Filters | (I:UTF-8/O:UTF-8)
2017-11-6 16:57:4.732 INFO [RMI TCP Connection(3)-127.0.0.1] Found 1 module methods
2017-11-6 16:57:4.733 DEBUG [RMI TCP Connection(3)-127.0.0.1] @Localization not define
2017-11-6 16:57:4.737 INFO [RMI TCP Connection(3)-127.0.0.1] Nutz.Mvc[nutz] is up in 291ms

@wendal

2017-11-6 16:57:4.590 INFO [RMI TCP Connection(3)-127.0.0.1] Resource can't map to Class, Resource service/Impl/IndexServiceImpl.class

这里报错了

需要改一些东西:

项目路径不要有空格或中文字符, 换新版nutz

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