如何在EAR之外移动环境细节 [英] How to move the environment details outside the EAR

查看:95
本文介绍了如何在EAR之外移动环境细节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目是在WAS 6.1 / hibernate / struts上使用RAD 7.0开发的中型Web应用程序,该应用程序已移至生产环境。目前我们已经在hibernate配置文件中的属性文件和数据库模式详细信息中对生产系统的IP地址进行了硬编码。

我们的客户希望我们提出解决方案,以便将环境细节保留在EAR的外面,以便他们可以在未来开放时更改环境/数据库细节EAR。



任何指针都会非常有帮助。谢谢。

解决方案

您可以使用JNDI来做到这一点。您应该创建适当的条目,并在您的代码中读取它们,如下所示:

  Context initialContext = new InitialContext(); 
URL ip =(URL)initialContext.lookup(java:comp / env / myip);

请参阅这篇关于如何在hibernate配置文件中使用JNDI数据源的文章。


Our project is a medium size web application developed using RAD 7.0 on WAS 6.1/hibernate/struts which moved to production. Currently we have hardcoded the ip address of the production system in the property file and database schema details in the hibernate config file.

Our client wants us to come up with the solution for keeping the environment details out side the EAR, so that they can change the environment/db details in future with out opening the EAR .

Any pointers would be very helpful. Thanks.

解决方案

You can use JNDI for this. You should create the appropriate entries and in your code read them like this:

Context initialContext = new InitialContext();
URL ip = (URL) initialContext.lookup("java:comp/env/myip");

See this article on how to use a JNDI Data Source in hibernate configuration files.

这篇关于如何在EAR之外移动环境细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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