开发和生产的属性 [英] Properties for dev and production

查看:139
本文介绍了开发和生产的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个GlassFish / j2ee应用程序,我开发一个盒子,生产是一个遥控盒。
我有一个功能,使文件,我需要的文件的位置是不同的,基于我的开发箱或生产。
什么是一种自动的切换方式,所以我不需要根据它被部署在哪里编辑源文件?

解决方案

最简单的方法是定义一个系统属性,指定数据的文件系统位置在哪里。生产应用服务器将定义一个值(在启动脚本中使用 java -D ),并且您的开发应用服务器将定义另一个值。您的应用程序来源将查询系统属性值(使用 System.getProperty())来发现适当的位置。


I have a GlassFish/j2ee application, and I develop on one box, and production is a remote box. I have a function that makes files, and I need the files' location to be different based on my dev box or production. What is an automatic way to do the switching so I do not have to edit the source file based on where it is being deployed?

解决方案

The easiest approach is to define a system property which specifies where the file system location for your data is. The production appserver would define one value (using java -D in the startup script), and your dev app server would define another value. Your application source would consult the system property value (using System.getProperty()) to discover the appropriate location.

这篇关于开发和生产的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆