JavaEE解决方案配置最佳实践 [英] JavaEE solution configuration best practices
问题描述
我们构建的三层企业解决方案通常由几个webapp和ejbjar模块组成,这些模块都与db通话并且有多个外部集成点。每个模块通常都是典型的需要自己的配置,可以改变解决方案的生命周期。
部署它成为一场噩梦,因为现在我们有18个属性文件必须被记住复制并配置设置数据源,队列,内存要求等。
我很有希望,但并不乐观,可以有更好的办法。
我们考虑/使用的一些选项,每个选项都有其优点和缺点:$ b
$ ol
有了这些,你仍然需要以容器特定的方式配置数据源和队列等:(
使用一个简单的数据库表(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:
- 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.
- 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.
- 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屋!