Java Web应用程序配置模式 [英] Java Web Application Configuration Patterns

查看:234
本文介绍了Java Web应用程序配置模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有任何模式或最佳实践可用于简化在多个环境中更改java Web应用程序的配置概要文件。例如JDBC URL,SOAP端点等。

Are there any patterns or best practices that can be used to simplify changing configuration profiles for java web applications across multiple environments. e.g. JDBC URLs, SOAP end-points, etc.

为了帮助阐明我的问题,我使用了几个大的java web应用程序,在任何给定的发布周期移动通过6个不同的环境;开发,集成,QA,性能,并最终部署到多个生产服务器。在每个环境中,配置都需要更改。现在,每个部署的大多数配置更改都是手动完成的,这既费时又容易出错。

有任何方法可以手动干预这个过程吗?

As a bit of background to help clarify my question, I work with several large java web applications that during any given release cycle move through 6 different environments; development, integration, QA, performance and eventually get deployed to multiple production servers. In each environment, configuration needs to change. Right now, most configuration changes for each deployment are done manually which is both time consuming and open to errors.
Is there any way to take the manual intervention out of this process?

推荐答案

我最近更喜欢使用.NET,所以我的Java相当生锈。

I tend to work more with .NET lately, so my Java is fairly rusty. I'm pretty sure this would work in any language with a little tweaking.

我们使用.NET配置系统的扩展,允许我们使用环境和/或应用程序特定设置结合更全局的配置。配置系统使用每个机器的全局设置将其标识为dev,beta或production(默认值)。按顺序加载的一组文件,来自上一个文件的设置将覆盖先前加载的文件中定义的任何设置。文件按以下顺序加载:

We use an extension of the .NET configuration system that allows us to use environment and/or application specific settings in conjunction with a more global configuration. The configuration system uses a Global setting to each machine identifies it as dev, beta, or production (the default). A set of files loaded in order, and the setting from the last file overrides any setting that was defined in a previously loaded file. Files are loaded in the following order:


  1. 全局设置

  2. 应用程序特定设置

  3. 应用程序特定的环境覆盖

所有文件都在源代码控制中,机器应用程序正在运行;因为它不会访问beta配置,除非机器配置将其标识为beta,我们可以提升所有配置文件,而不必担心无意中将我们的生产应用程序指向dev数据库。

All the files are in source control, and since the environment is defined on the machine the application is running on; since it won't access the "beta" configuration unless the machine configuration identifies it as "beta", we can promote all of the configuration files without fear of inadvertently pointing our production application to a dev database.

这篇关于Java Web应用程序配置模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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