NutzCN Logo
问答 求教一个ioc注入死循环的问题
发布于 107天前 作者 qq_b54b367e 102 次浏览 复制 上一个帖子 下一个帖子
标签:

先贴代码

@IocBean
public class IocBeans {
	@Inject("refer:$ioc")
	Ioc ioc;

	@IocBean(name = "businessController")
	public BaseController getBusinessController() {
		if (ProjectType.xzfwzx.equals(CacheData.project_type)) {
			return ioc.get(XBusinessController.class);
		}
		return ioc.get(BusinessController.class);
	}
}
@IocBean
@At("/base/business")
public class BusinessApi {
	@Inject
	BusinessController businessController;
	
	@At("/getBusinesses")
	@Ok("json")
	@AdaptBy(type = JsonAdaptor.class)
	public Object getBusinesses(@Param("venueId") Integer venueId) {
		if(venueId==null) {
			return Result.error(ErrorCode.PARAMETER_ERROR, "参数缺失");
		}
		return businessController.getBusinesses(venueId);
	}
	
	@At("/getBusinessesType")
	@Ok("json")
	@AdaptBy(type = JsonAdaptor.class)
	public Object getBusinessesType(@Param("venueId") Integer venueId) {
		if(venueId==null) {
			return Result.error(ErrorCode.PARAMETER_ERROR, "参数缺失");
		}
		return businessController.getBusinessesType(venueId);
	}
}

BusinessController继承BaseController,XBusinessController继承BusinessController
当ProjectType.xzfwzx.equals(CacheData.project_type)条件为false时,
getBusinessController方法递归死循环

1 回复

BusinessController类加一个 @IocBean(name="defaultBusinessController")

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