JavaEE解决方案配置最佳实践 [英] JavaEE solution configuration best practices

查看:147
本文介绍了JavaEE解决方案配置最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们构建的三层企业解决方案通常由几个webapp和ejbjar模块组成,这些模块都与​​db通话并且有多个外部集成点。每个模块通常都是典型的需要自己的配置,可以改变解决方案的生命周期。
部署它成为一场噩梦,因为现在我们有18个属性文件必须被记住复制并配置设置数据源,队列,内存要求等。



我很有希望,但并不乐观,可以有更好的办法。
我们考虑/使用的一些选项,每个选项都有其优点和缺点:$ b​​
$ ol
  • 使用多个maven项目和持续集成(例如hudson或jenkins)来构建一个配置jar,该jar包含每个环境(dev,qa,prod)的所有属性文件,然后将所有内容捆绑为EAR。但是,如果需要的话,生产过程中不容易改变。

  • 将大部分设置放在数据库中,并有一个简单的屏幕来修改它。在内部,我们可以有一个通用配置服务EJB,它可以读取和修改这些值。每个模块都可以有一个自定义的扩展版本,它具有特定的getter和setter。
  • 版本控制所有属性文件,然后在生产时检查它,并在修改后将其检入生产分支。 / li>

    有了这些,你仍然需要以容器特定的方式配置数据源和队列等:(

    解决方案

    使用一个简单的数据库表(Section,Key,Value)。如果需要,添加Version ConfigurationService类的方法如 getInt(String section,String key)



    不是很多工作,它使应用程序代码非常整齐,并且配置调整非常简单。


    We build 3-tier enterprise solutions that typically consists of several webapp and ejbjar modules that all talk to a db and have several external integration points.

    Each module typically needs its own configurations that can change over the solution's life time. Deploying it becomes a nightmare because now we have 18 property files that must be remembered to copied over and configured also setting up data-sources, queues, memory requirements etc.

    I'm hopeful but not optimistic that there can be a better way. Some options we've considered/used, each with it's pros and cons:

    1. Use multiple maven projects and continuous integration (eg. hudson or jenkins) to build a configuration jar that includes all the property files for each environment (dev, qa, prod) and then bundle everything up as an EAR. But then things can't be easily changed in production when needed.
    2. Put most of the settings in the DB and have a simple screen to modify it. Internally we can have a generic configuration service EJB that can read and modify the values. Each module can have a custom extended version that have specific getters and setter.
    3. Version control all the property files then check it out on production and check it into a production branch after making changes.

    With all of these you still need to configure data-sources and queues etc. in a container specific way :(

    解决方案

    User a simple database table (Section, Key, Value). Add "Version" if you need it, and wrap the entire thing in a simple ConfigurationService class with methods like getInt(String section, String key)

    Not a lot of work, and it makes the application code very neat, and tweaking with the configuration very easy.

    这篇关于JavaEE解决方案配置最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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