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

查看:34
本文介绍了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 配置系统的扩展,允许我们将环境和/或应用程序特定设置与更全局的配置结合使用.配置系统使用全局设置将每台机器标识为开发、测试或生产(默认).一组按顺序加载的文件,最后一个文件的设置会覆盖先前加载的文件中定义的任何设置.文件按以下顺序加载:

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",因此我们可以提升所有配置文件而不必担心无意中将我们的生产应用程序指向开发数据库.

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天全站免登陆