最简单的方法是定义一个系统属性,指定数据的文件系统位置在哪里。生产应用服务器将定义一个值(在启动脚本中使用 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.
更多推荐
开发和生产的属性
发布评论