NutzCN Logo
问答 nutz 加载properties
发布于 3068天前 作者 qq_7e14da0b 2826 次浏览 复制 上一个帖子 下一个帖子
标签: ioc

mystep 中如何获取 properties里的东西?
在一个java类中又该如何获取。

6 回复

mystep 是什么东西...

如果有ioc的话, 配置了PropertiesProxy的话, 可以注入

http://nutzbook.wendal.net/dev_prepare/better_dao_js.html

@wendal MainSetup 写错了。 没有ioc 环境的话该怎么获取?

你指的没Ioc是整个Mvc应用都不需要Ioc, 还是说拿不到ioc容器的地方

如果是后者

Mvcs.ctx().getDefaultIoc().get(XXXXX.class, xxxx)

前者, 直接new PropertiesProxy或者用jdk的Properties完事

@wendal 是在没有ioc容器的地方。 取db.properties里的值。用new PropertiesProxy 取不出来啊
PropertiesProxy pp= new PropertiesProxy();
String driver= pp.get("db.driver");
System.out.println(driver);

起码告知一下路径吧

PropertiesProxy pp= new PropertiesProxy("conf/"); // 文件夹,具体文件, 均可
添加回复
请先登陆
回到顶部