简体   繁体   English

jar文件位置-耳文件或服务器lib文件夹?

[英]jar file location - ear file or server lib folder?

When deploying an application to JBoss server, for a JAR like ojdbc14.jar (Oracle JDBC), is it better to include this jar in the ear file of the deployment, or should it be deployed to JBoss's server/default/lib folder? 将应用程序部署到JBoss服务器时,对于像ojdbc14.jar(Oracle JDBC)这样的JAR,最好将这个jar包含在部署的ear文件中,还是应该将其部署到JBoss的server / default / lib文件夹中?

The argument I've been given is that the application needs to support global transactions, hence the datasource must be defined at the application server level (eg copied to server/default/lib folder) so it can talk to other app servers, and for that to happen you need the drivers at the app server level. 我得到的论点是应用程序需要支持全局事务,因此数据源必须在应用程序服务器级别定义(例如,复制到server / default / lib文件夹),以便它可以与其他应用程序服务器通信,并且为此,您需要应用服务器级别的驱动程序。

I'd like to hear what is the correct approach here. 我想听听这里的正确方法是什么。 Thanks. 谢谢。

I believe this is the correct approach. 我相信这是正确的方法。

You will typically define your datasource outside of your application (outside of your EAR/WAR) using the appropriate configuration files depending upon the application server you are using. 通常,您将根据使用的应用程序服务器,使用适当的配置文件在应用程序外部(EAR / WAR外部)定义数据源。 Whereas on JBoss, you usually add your configuration to XML files, with WebLogic, you can create a datasource directly using the Admin console. 在JBoss上,通常将配置添加到XML文件中,而使用WebLogic,则可以直接使用管理控制台创建数据源。

Given that this datasource will be created on server startup, the necessary libraries (in your case, ojdbc14.jar) must be available on the classpath of the application server. 假定此数据源将在服务器启动时创建,则必需的库(在您的情况下为ojdbc14.jar)必须在应用程序服务器的类路径上可用。

I have also come across licensing issues where the use of a 3rd party library prevents you from bundling it within your application. 我还遇到了许可问题,在这种情况下,使用第三方库会阻止您将其捆绑到应用程序中。

Also, defining your datasource outside of your application means you do not have to perform a rebuild when the datasource configuration needs to change. 同样,在应用程序外部定义数据源意味着当数据源配置需要更改时,您不必执行重建。

So many time I have done that... 我已经做了很多次了...

I will always put the jar inside the server/default/lib folder if it has something to have about JDBC. 如果它与JDBC有关,我将始终将jar放在server/default/lib文件夹中。

Because your database driver is loaded one time as soon as the server is started, and not each time you deploy/undeploy the webapplication your are working on. 因为数据库驱动程序是在服务器启动后一次加载的,而不是在每次部署/取消部署您正在使用的Web应用程序时加载的。

Your datasources will be availiable for any others sub-projects too, and it will be a great advantage when you have a specific project for integration testing purpose. 您的数据源也可用于任何其他子项目,当您具有用于集成测试目的的特定项目时,这将是一个很大的优势。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM