NutzCN Logo
问答 就是我在controller层 使用@Inject这个注解 就抛出这个错误 是什么啊- -
发布于 2557天前 作者 lalala 2716 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk
org.nutz.ioc.IocException: IocBean[testModule] 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 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)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.xhd.shop.admin.processor.LogTimeProcessor.process(LogTimeProcessor.java:23)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1126)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1060)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
	at org.eclipse.jetty.server.Server.handle(Server.java:509)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:288)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:240)
	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:539)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:620)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:540)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: IocBean[testModule] fail at field=[userService]
	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)
	... 33 more
Caused by: org.nutz.ioc.IocException: IocBean[cmsUserServiceImpl] 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.getByType(NutIoc.java:395)
	at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:66)
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32)
	... 35 more
Caused by: org.nutz.lang.born.BorningException: Fail to born or cast to 'com.xhd.shop.core.services.admin.impl.CmsUserServiceImpl'
 by args: []
 because: No suitable Constructor or Factory Method!!
	at org.nutz.lang.Mirror.getBorning(Mirror.java:954)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:107)
	... 39 more
15 回复
@IocBean(args = {"refer:dao"})
public class CmsUserServiceImpl extends BaseServiceImpl<cms_user> implements CmsUserService {
    public CmsUserServiceImpl(Dao dao) {
        super(dao);
    }

都有了啊 - - 我想实现nutzwk的base封装方式

报错之前的10行日志也贴一下

2017-11-15 14:47:07 [org.nutz.ioc.loader.combo.ComboIocLoader]-[DEBUG] Found IocObject(cmsUserServiceImpl) in AnnotationIocLoader(packages=[com.xhd.shop])
2017-11-15 14:47:07 [org.nutz.ioc.impl.NutIoc]-[DEBUG] Get 'cmsUserServiceImpl'<interface com.xhd.shop.core.services.admin.CmsUserService>
2017-11-15 14:47:07 [org.nutz.ioc.impl.NutIoc]-[DEBUG] 	 >> Load definition name=cmsUserServiceImpl
2017-11-15 14:47:07 [org.nutz.ioc.loader.combo.ComboIocLoader]-[DEBUG] Found IocObject(cmsUserServiceImpl) in AnnotationIocLoader(packages=[com.xhd.shop])
2017-11-15 14:47:07 [org.nutz.ioc.impl.NutIoc]-[DEBUG] 	 >> Make...'cmsUserServiceImpl'<interface com.xhd.shop.core.services.admin.CmsUserService>
2017-11-15 14:47:07 [org.nutz.ioc.aop.impl.DefaultMirrorFactory]-[DEBUG] Load class com.xhd.shop.core.services.admin.impl.CmsUserServiceImpl without AOP
2017-11-15 14:47:07 [org.nutz.ioc.impl.ScopeContext]-[DEBUG] Save object 'cmsUserServiceImpl' to [app] 
2017-11-15 14:47:07 [org.nutz.ioc.impl.ScopeContext]-[DEBUG] Remove object 'cmsUserServiceImpl' from [app] 
2017-11-15 14:47:07 [org.nutz.ioc.impl.ScopeContext]-[DEBUG] Remove object 'testModule' from [app] 
2017-11-15 14:47:07 [com.xhd.shop.admin.processor.LogTimeProcessor]-[DEBUG] [GET ]URI=/test/jetx 11ms
2017-11-15 14:47:07 [org.nutz.mvc.impl.processor.FailProcessor]-[WARN] Error@/test/jetx :

加个无参数构造方法试试


public class BaseServiceImpl<T> extends EntityService<T> implements BaseService<T>{ public BaseServiceImpl(Dao dao) { super(dao); } ... public interface BaseService<T> { Dao dao(); int count(Condition cnd);

TestModule贴来看看

@IocBean
@At("/test")
public class TestModule {
    private static final Log log = Logs.get();
    @Inject
    private CmsUserService userService;

    @At("/str")
    @Ok("json")
    public String  test1(){
        log.info("ll");
        return "guojxx";
    }

    @At("/jetx")
    @Ok("jetx:hello.jetx")
    public void  jext(){
    }

    @At("/dao")
    public Object  testDao(@Param("::user.")cms_user user){
        return  null;
    }

    @At("/ser")
    @Ok("json")
    public Object testSer(){
        return  userService.query(Cnd.where("id","=","1"),"roleId");
    }
}

额,是不是项目没clean啊... 看不出哪里问题

额额额。。。对maven不太熟悉 多模块项目我直接启动。。

不过好像还是一样。。。

执行一下clean和install

什么情况?

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