我应该在应用程序或应用程序服务器中定义数据源吗? [英] Should I define datasources in application or in app server?

查看:112
本文介绍了我应该在应用程序或应用程序服务器中定义数据源吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了两个不同团队的应用程序(在Jboss服务器上运行)。一个团队在应用程序WAR文件中有数据源配置,另一个团队在应用程序服务器的standalone.xml内部有数据源配置。而且我不确定哪种方法更好。

I've developed applications (running on Jboss server) with two different teams. One team had datasource configuration inside of the application WAR file and another one had it inside of the application server's standalone.xml. And I'm not sure which approach is better.

因此,我在服务器的standalone.xml中定义数据源时发现了一些优点。

So, here are some advantages that I've found in defining datasource inside of the server's standalone.xml.


  • 在服务器的standalone.xml中定义数据源比在war文件中更安全。如果数据库连接凭证存储在服务器的standalone.xml中,几乎从未修改过,它比war文件中的密码更安全,war文件经常从开发人员的机器传输到服务器,所有开发人员都会传播数据库配置计算机。

  • 通过在standalone.xml中使用数据源,我们可以使war文件更小,因为JDBC驱动程序可以作为模块安装,并且可以从war文件中删除。此外,从类路径加载JDBC作为模块更有效。

  • 如果我们不希望应用程序开发团队知道数据库连接,我们可以将数据源放在standalone.xml中设置。

通过在应用程序WAR文件中使用数据源配置,我看到了以下优点:

By having datasource configurations in application WAR file, I see the following advantages, which are:


  • 开发团队无权在运行Jboss的环境中更改Jboss配置文件。因此,只能在应用程序中定义数据库连接。

  • 当开发人员经常需要在不同的数据库连接之间切换时,它在开发状态下很有用。例如,开发人员可以在构建WAR文件时指定连接。

所以我想知道是否还有其他优点两种方法。并且您认为哪种方法更好?

So I'd like to know if there are another advantages in both approaches. And on your opinion which approach is better?

推荐答案

除了问题中提到的要点之外,拥有数据源的另一个优势在应用程序之外是它允许在不同区域使用相同的war文件。这将允许团队在使用相同的war文件时为不同的环境(如Test,Perf和Prod)提供不同的数据库。

In addition to the points noted in the question, another advantage in having the datasources outside the application is that it allows for using the same war file in different regions. This would allow the team to have different databases for different environments, like Test, Perf and Prod while using the same war file.

您可以进行一次部署然后进行部署经过QA团队测试的war文件可以升级到生产区域。这样可以确保没有未经测试的代码进入更高的区域,同时避免了SCM分支和代码冻结的需要。

You can do a deployment once and then the war file which has been tested by your QA team can be promoted to the production region. This would make sure that no untested code goes into higher regions while avoiding the need for SCM forks and code freezes.

这篇关于我应该在应用程序或应用程序服务器中定义数据源吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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