NutzCN Logo
问答 自关联时报错,nutz可以自关联创建表吗
发布于 2455天前 作者 yuffo 1784 次浏览 复制 上一个帖子 下一个帖子
标签:
/**
 * 菜单表
 * @author 49715
 */
@Table
@Comment
public class Menu {
	@Id
	private Integer id;

	@One
	@Comment("父级菜单")
	private Menu parent;

	@Many
	@Comment("子菜单")
	private List<Menu> childrens;

	@Column
	@Comment("本菜单指向的地址")
	private String url;

	@Column
	@Comment("在同级菜单中的排序")
	private String order;
//getting/setting.....

主模块的init 创建表

	//使用h2数据库时 创建表
	public void init() {
		Daos.createTablesInPackage(dao, "com.boyuan.metrial.po", false);
		Daos.migration(dao, "com.boyuan.metrial.po", true, false, false);
		for (int i = 0; i < 20; i++) {
			qualityService._fastInsert(JMockData.mock(Quality.class));
		}
	}

启动时报错

[DEBUG] 08:53:43.891 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:164) - Get 'dao'<>
[DEBUG] 08:53:43.891 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:164) - Get 'roleService'<class com.boyuan.metrial.service.RoleService>
[DEBUG] 08:53:43.892 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:190) - 	 >> Load definition name=roleService
[DEBUG] 08:53:43.892 org.nutz.ioc.loader.combo.ComboIocLoader.printFoundIocBean(ComboIocLoader.java:226) - Found IocObject(roleService) in AnnotationIocLoader(packages=[com.boyuan.metrial])
[DEBUG] 08:53:43.892 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:221) - 	 >> Make...'roleService'<class com.boyuan.metrial.service.RoleService>
[DEBUG] 08:53:43.892 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:64) - Save object 'roleService' to [app] 
[DEBUG] 08:53:43.892 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:76) - Load class com.boyuan.metrial.service.RoleService without AOP
[DEBUG] 08:53:43.894 org.nutz.service.EntityService.<init>(EntityService.java:41) - Get TypeParams for self : com.boyuan.metrial.po.Role
[DEBUG] 08:53:43.894 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:164) - Get 'dao'<>
[DEBUG] 08:53:43.894 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:164) - Get 'dao'<interface org.nutz.dao.Dao>
[DEBUG] 08:53:43.902 org.nutz.resource.Scans.scan(Scans.java:280) - Found 6 resource by src( com/boyuan/metrial/po/ ) , regex( ^.+[.]class$ )
[DEBUG] 08:53:43.935 org.nutz.ioc.impl.ScopeContext.remove(ScopeContext.java:84) - Remove object 'mainLauncher' from [app] 
[ERROR] 08:53:43.936 org.nutz.boot.NbApp._run(NbApp.java:202) - something happen!!
org.nutz.ioc.IocException: IocBean[mainLauncher] throw Exception when creating
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:152)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:269)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:159)
	at org.nutz.boot.NbApp._run(NbApp.java:193)
	at org.nutz.boot.NbApp.run(NbApp.java:170)
	at com.boyuan.metrial.MainLauncher.main(MainLauncher.java:43)
Caused by: org.nutz.dao.DaoException: Invalid @One(field=parentId) 'parent' : class com.boyuan.metrial.po.Menu<=>class com.boyuan.metrial.po.Menu
	at org.nutz.dao.impl.entity.field.OneLinkField.<init>(OneLinkField.java:38)
	at org.nutz.dao.impl.entity.AnnotationEntityMaker.make(AnnotationEntityMaker.java:290)
	at org.nutz.dao.impl.EntityHolder.getEntity(EntityHolder.java:72)
	at org.nutz.dao.impl.NutDao.getEntity(NutDao.java:682)
	at org.nutz.dao.util.Daos$3.compare(Daos.java:464)
	at org.nutz.dao.util.Daos$3.compare(Daos.java:462)
	at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
	at java.util.TimSort.sort(TimSort.java:220)
	at java.util.Arrays.sort(Arrays.java:1512)
	at java.util.ArrayList.sort(ArrayList.java:1462)
	at java.util.Collections.sort(Collections.java:175)
	at org.nutz.dao.util.Daos.createTablesInPackage(Daos.java:462)
	at com.boyuan.metrial.MainLauncher.init(MainLauncher.java:35)
	at com.boyuan.metrial.MainLauncher$FM$init$62febe830a4a6764c634d9e263964cee.invoke(MainLauncher.java)
	at org.nutz.ioc.impl.ObjectMakerImpl$2.trigger(ObjectMakerImpl.java:180)
	at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:89)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:141)
	... 6 more
[DEBUG] 08:53:43.943 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:164) - Get 'jettyStarter'<interface org.nutz.boot.starter.ServerFace>
[INFO ] 08:53:43.953 org.eclipse.jetty.server.AbstractConnector.doStop(AbstractConnector.java:331) - Stopped ServerConnector@401f4f47{HTTP/1.1,[http/1.1]}{127.0.0.1:80}
[INFO ] 08:53:43.953 org.eclipse.jetty.server.session.HouseKeeper.stopScavenging(HouseKeeper.java:167) - Stopped scavenging
[INFO ] 08:53:43.955 org.nutz.boot.starter.nutz.mvc.NbMvcLoading.depose(NbMvcLoading.java:54) - Nutz.Mvc[nutz] is deposing ...
[INFO ] 08:53:43.955 org.nutz.boot.starter.nutz.mvc.NbMvcLoading.depose(NbMvcLoading.java:70) - Nutz.Mvc[nutz] is down in 0ms
[INFO ] 08:53:43.958 org.eclipse.jetty.server.handler.ContextHandler$Context.log(ContextHandler.java:2221) - Cleaning up Shiro Environment
[INFO ] 08:53:43.960 org.eclipse.jetty.server.handler.ContextHandler.doStop(ContextHandler.java:957) - Stopped o.e.j.w.WebAppContext@6bd16207{/,[file:///C:/Users/49715/Downloads/material/target/classes/static/, jar:file:/C:/Users/49715/.m2/repository/org/nutz/nutzboot-starter-swagger/2.1.1/nutzboot-starter-swagger-2.1.1.jar!/static/],UNAVAILABLE}
[INFO ] 08:53:44.052 org.nutz.ioc.impl.NutIoc.depose(NutIoc.java:285) - org.nutz.ioc.impl.NutIoc@276777344 is closing. startup date [18-04-04 08:53:41.119]
4 回复

小白,wendal老师parentId是啥,我也出现楼主的错误了

 16:23:54.628 org.nutz.boot.NbApp.execute(NbApp.java:218) - something happen!!
org.nutz.ioc.IocException: IocBean[dubboRpcCmsMainLauncher] throw Exception when creating

@wendal 求教

@Column
private Integer parentId;

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