-
Notifications
You must be signed in to change notification settings - Fork 941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
怎么在非servlet或者action中获取ioc中的实例 #273
Comments
Mvcs.getIoc()仅在请求范围内有效 你可以通过@SetupBy, 使用自己的Setup类, 将Ioc容器保存到自己的静态变量中 |
如果你的对象是由 Ioc 容器组装的,你可以声明一个成员变量
容器会把自身的引用设置给你这个变量,相关文档 http://code.google.com/p/nutz/wiki/ioc_injecting#容器自身 |
"@SetupBy, 使用自己的Setup类, 将Ioc容器保存到自己的静态变量中",用这个搞法真的很绝! |
@xie041 通过 @SetupBy 你可以做更多更绝的事情 :P |
启动的时候,自动把bean映射到数据库,这样搞合适不? |
哦,我一般也是这么搞,不过我都是写死的。写一排 dao.create(XXXX.class, false) |
Dao dao = Mvcs.getIoc().get(Dao.class, "dao");
获取不到?The text was updated successfully, but these errors were encountered: