在两个 JBoss 应用程序中为同一数据源配置不同的物理数据库
我想在 JBoss 6.0 服务器实例中部署相同的 Java EE 企业应用程序两次(使用两个不同的名称)。 这两个应用程序都使用服务器中配置的相同逻辑数据源。 到目前为止没有问题。
然而,我想通过这个唯一的逻辑数据源将两个应用程序中的每一个定位到不同的物理数据库。
JBoss 6.0 是否可以以某种方式实现这一点(无需使用两个不同的服务器实例或在部署之前更改应用程序或在每个应用程序中打包不同的 *ds.xml 文件?)
I want to deploy the same Java EE enterprise application twice (under two different names)in a JBoss 6.0 server instance.
Both of these applications use the same logical datasource as configured in the server.
No problem so far.
Yet, I'd like to target each of the two applications a different physical database through this one and only logical datasource.
Is that possible with JBoss 6.0 somehow (without using two different server instances or changing the application before deployment or packaging different *ds.xml files in each application?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
同一个 *-ds.xml 文件下有两个不同的数据源:
唯一的缺点是,如果您使用 @Resource 注释,则必须自定义代码:
尚未尝试以下操作,但您也许可以通过InitialContext 进行显式JNDI 查找,并指定要在属性文件(DS1 / DS2) 中查找的资源?如果您使用 Maven(我现在做了多个假设:))您可以 过滤属性文件并在构建时通过配置文件提供正确的数据库数据源名称。
Two different data sources under the same *-ds.xml file:
The only downside is that you have to customize your code if you are using the @Resource annotation:
Haven't tried the following, but you might be able to do a explicit JNDI lookup via InitialContext, and specify the resource to be looked up in a properties file (DS1 / DS2)? If you are using Maven (I am making multiple assumptions now :)) you could filter the properties file and provide the right DB datasource name via profiles during build time.