NutzCN Logo
精华 对于开发环境,测试环境,生产环境,配置无修改,实现动态取得配置文件,摆脱频繁修改配置文件的苦恼
发布于 1928天前 作者 threefish 1679 次浏览 复制 上一个帖子 下一个帖子
标签:
var ioc = {
    conf: {
        type: "org.nutz.ioc.impl.PropertiesProxy",
        fields: {
            paths: ["custom/"]
        }
    },

.....略 

1、首先 认定 custom 为生产目录
2、在VM OPTION 中增加 -Dnutzfw.conf.path=dev/custom/

注意:多目录替换例子 -Dnutzfw.conf.path=dev/custom/,dev/custom2/

启动后程序将识别Dnutzfw.conf.path 并将指向custom/的路径修改为dev/custom/不影响默认功能

PropertiesProxy (稍后我会提交PR对该类进行极少量代码修改)

4 回复

应该是 -Dnutz.conf.path=

正确示例,此楼以上不做数

var ioc = {
    conf: {
        type: "org.nutz.ioc.impl.PropertiesProxy",
        fields: {
            keyIndex:1,//可选(不可重复) 匹配 -Dnutz.conf.path.1=dev/custom/,dev/custom1/
            paths: ["custom/"],//上面的配置将替换我
        }
    },
    enumsConf: {
        type: "org.nutz.ioc.impl.PropertiesProxy",
        fields: {
            keyIndex:2,//可选(不可重复) 匹配 -Dnutz.conf.path.2=dev/custom/,dev/custom1/
            paths: ["enums/"],//上面的配置将替换我
        }
    },
    enumsConfTest: {
        type: "org.nutz.ioc.impl.PropertiesProxy",
        fields: {
            paths: ["enums/"]
        }
    }
}

运行时添加VM OPTION时可以根据KEYINDEX 替换目录

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