NutzCN Logo
问答 mainSetup 添加带接口userService
发布于 2858天前 作者 chafferer 1997 次浏览 复制 上一个帖子 下一个帖子
标签:

nutzBook里面是实现方法直接写到userService里面了,但是我有点强迫症,喜欢都分开,所以有userService 和userServiceImpl,但是在mainSetup里面获取的时候就报错了,下面贴上代码:

public interface UserService {
	User add(String name, String password);
	int fetch(String username, String password);
	void updatePassword(int userId, String password);
	
}
@IocBean(fields="dao")
public class UserServiceImpl extends IdNameEntityService<User> implements UserService  {

  //。。。实现方法

}
org.nutz.mvc.LoadingException: org.nutz.ioc.IocException: [userService] # For object [userService] - type:[interface com.cdroid.nutz.service.UserService]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:17)
	at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
	at org.nutz.lang.Mirror.born(Mirror.java:990)
	at org.nutz.lang.Lang.wrapThrow(Lang.java:197)
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:135)
	at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
	at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
	at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
	at com.cdroid.nutz.mvc.CdroidNutFilter.init(CdroidNutFilter.java:25)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4797)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5473)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.nutz.ioc.IocException: [userService] # For object [userService] - type:[interface com.cdroid.nutz.service.UserService]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:218)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:146)
	at com.cdroid.nutz.mainSetup.init(mainSetup.java:24)
	at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:277)
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:121)
	... 16 more
Caused by: org.nutz.ioc.ObjectLoadException: Object 'userService' without define!
	at org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:174)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:180)
	... 21 more

求大大帮忙

5 回复

mainSetup 里面代码:

// 初始化默认根用户
        if (dao.count(User.class) == 0) {
            UserService us = ioc.get(UserService.class);
            us.add("admin", "123456");
        }

。。尴尬,可以了,impl的iocBean 要加上name属性

后面做email的时候有这种配置

话说,你用的是什么版本?

@wendal 1.r.60 ..刚接触直接从最新的开始了

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