一个Java EE项目的建筑 [英] Architecture of a Java EE project

查看:104
本文介绍了一个Java EE项目的建筑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个EAR和4个战争中的Java EE项目。我有一个在战争中使用的一些的POJO。它们包含静态变量和方法,应该是在整个战争相同的类。
应该在哪里他们放在哪里?

I have a Java EE project with an EAR and 4 WARs. I have some pojos that are used in the wars. They are classes which contain static variables and methods and should be the same across the WARs. Where should they be placed?

一些背景:我继承了这个项目,在战争中的一个常用的POJO。不过,我想战争的全部4个指一些新的staticly访问类的同一个实例。这是不可能的,在战争中的一个拿着他们,因为每个WAR似乎把它的静态类的运行时实例,并在一个WAR改变类,并没有导致另一场战争改变的类。

Some background: I had inherited the project with the frequently used pojos in one of the wars. However I wanted all 4 of the WARs to refer to the same instance of some new staticly accessed classes. This was not possible with them held in one of the wars, as each WAR appeared to take it's own runtime instance of the static classes, and changing the class in one WAR, did not result in a change to the class in another WAR.

所以打击安装在JAR此I和部署到服务器。但是,现在每个项目部署JAR时,还必须构建和安装太多,如果它已经改变了在服务器上。

So to combat this I installed in a JAR and deployed that to the server. But now every time the project is deployed the JAR must also be built and installed on the server too if it has changed.

谁在这里部署该人不喜欢这个建筑,我想知道是否有另一种方式来做到这一点?

The person who deploys that here doesn't like this architecture and I wondered if there was another way to do it?

推荐答案

是的,WAR文件将分别根据自己的类加载器加载,所以他们不看对方的类。

Yes, WAR files will each be loaded under their own classloader, so they do not see each other's classes.

您可以将一个JAR文件的EAR的根源,是指它在每个每个WAR.These JAR文件的清单有时被称为实用程序JAR。

You can place a JAR file in the root of the EAR and refer to it in the Manifest of each each WAR.These JARs are sometimes called "utility JARs".

我同意这种类型的自包含部署是preferable具有一个单独的JAR文件的其他地方。

I agree that a self-contained deployment of this kind is preferable to having a separate JAR file somewhere else.

这篇关于一个Java EE项目的建筑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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