立即重新部署Java EE应用程序 [英] Redeploying Java EE applications immediately

查看:187
本文介绍了立即重新部署Java EE应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java EE的新手,并且一直在努力解决部署过程的缓慢问题,并想知道我是否做错了什么。我对Django很有经验,其中代码的更改立即发生,似乎热部署Java EE应用程序有点令人困惑 - 有很多事情声称热部署(Glassfish,Eclipse manic hotdeploy,Jetty hotdeploy,JRebel等。 )。

I am quite new to Java EE and have been struggling with the slowness of the deployment process, and wonder if I'm doing something wrong. I am experienced with Django where the changes to code immediately occur, and it seems that hot deploying Java EE applications are a bit confusing -- there are multiple things which claim to hot deploy (Glassfish, Eclipse manic hotdeploy, Jetty hotdeploy, JRebel etc.).

我的项目是一个Maven项目,我正在使用Netbeans进行部署。该站点使用Spring,JSF和Hibernate框架。

My project is a Maven project and I'm using Netbeans to deploy. The site uses Spring, JSF and Hibernate frameworks.

在Netbeans中,Deploy on Save,根据以下屏幕截图似乎已启用,但点击/取消点击是不可能的,因为它声称从我的pom.xml获取信息(虽然我的pom.xml中没有这样的字段(只有依赖项))。

In Netbeans, Deploy on Save, according to the following screenshot seems to be enabled, but clicking/unclicking is not possible since it claims to get the info from my pom.xml (though there is no such field in my pom.xml (only dependencies)).

现在,对某些文件的更改似乎立即生效。其中包括:
- JSF文件
- 静态文件

Now, changes to some files seem to be effective immediately. These include: - JSF files - Static files

以下需要部署的更改:
- 任何XML文件
- 任何属性文件,甚至本地化属性文件
- 任何java文件

Changes to following require deployment: - Any XML file - Any properties file, even localization properties files - Any java file

对这些文件的更改要求我手动部署 并重新部署需要半分钟即使我目前只有2-3个类,基本上只有一个用户类和一个授权类。该项目目前只允许登录,尽管如此,编译大约需要几秒钟;容器(Glassfish)似乎消耗了大约600 MB的RAM,甚至在几次部署后也会出现PermGen错误,我需要使用任务管理器来终止java进程。 (我已经读过这与每次重新部署后的垃圾收集器泄漏有关,我甚至使用jhat生成一个配置文件,但是它提供了一个包含数千个类,我的类,Spring,Hibernate类等的列表。)

Changes to those require me to deploy manually and redeploying takes half a minute even though I currently have only 2-3 classes, basically a single user class and an authorization class. The project allows just logins at the moment, and despite this, the compilation takes around a few seconds; and the container (Glassfish) seems to consume around 600 MB of RAM and even gives PermGen errors after a few deployments and I need to kill the java process using Task Manager. (I have read that this is related to garbage collector leaking after each redeploy, and I have even used jhat to generate a profile, but was presented with a list of thousands of classes, my classes, Spring, Hibernate classes etc.)

我也听说过jrebel,并尝试运行它,但它似乎与我的Netbeans版本(7.0)不兼容,即使它似乎运行,任何修改任何java文件仍然需要重新部署。

I have heard about jrebel as well, and tried running it, but it seems that it is not compatible with my Netbeans version (7.0) and even though it seems to run, any modification to any java file still requires a redeploy.

我能做些什么来解决这些问题,或者在Java EE中等待大约1分钟是否正常每次更改任何Java文件后?这个问题严重影响了生产力。

Is there anything I can do to remedy these issues, or is it just normal in Java EE to wait for around 1 minute after each change to any Java file? This issue kills productivity significantly.

这是我部署应用程序时的Glassfish输出: http://pastebin.com/7FhZ6AVh

Here is my Glassfish output when deploying the application: http://pastebin.com/7FhZ6AVh

推荐答案

我发现既不可信也不官方来源但既然你没有答案,我想指出我发现的两件事。

I've found neither credible nor official sources but since you have no answers I'd like to point out two things I've discovered.

第一个是此常见问题解答在NetBeans站点上描述如何为Maven项目保存编译。默认情况下,此设置似乎处于关闭状态,默认情况下仅适用于测试。为方便起见:

The first is this FAQ on the NetBeans site describing how to turn on compile on save for a Maven project. It appears that this setting is off by default and only on by default for tests. For convenience:


转到项目属性对话框编译面板,将其打开以进行主源执行还有。

Go to the project properties dialog, Compile panel, to turn it on for main source execution as well.

第二个是,我必须强调我完全不明白这一点,似乎有两个不同NetBeans部署Web应用程序的方式。第一种方式是就地部署,看起来与手动将 .war 文件部署到服务器相同。第二个是增量部署,如果它类似于增量编译,则意味着当您的应用程序进行热部署时,您只需部署更改的文件。

The second is, and I must stress that I don't quite understand this completely, there seems to be two different ways that NetBeans deploys a Web Application. The first way is an in-place deployment that appears to be the same as deploying a .war file to the server manually. The second is an incremental deployment, which if it's anything like incremental compilation it means that when your app is hot-deployed you are only deploying the changed files.

当你点击运行或<$ c时,就地部署似乎是默认的部署方法$ c>从项目的上下文菜单中部署。增量部署在您的项目已部署并且再次单击运行(或使用运行工具栏按钮)时发生。

The in-place deployment seems to be the default method of deployment when you either click Run or Deploy from the projects' context menu. The incremental deployment happens when your project is already deployed and you click Run again (or use the Run toolbar button).

我想指出NetBeans FAQ,虽然在netbeans.org网站上不是官方出版物。任何人都可以创建一个常见问题解答,这些信息可以并且将在没有修订的情况下过时。

I'd like to point out that the NetBeans FAQ, although on the netbeans.org website is not an official publication. Anyone can create a FAQ and the information can and will become obsolete without revision.

编辑:经过一番反思后我决定所谓的增量部署不是一种不同的部署方式,只是第二次你运行你的应用程序就会进行增量部署。

Edit: After a little reflection I've decided that the so called incremental deployment is not a different way of deployment it's just that the second time you Run your application it does an incremental deployment.

编辑:请注意,上面的说明指向编译面板,而不是运行您在屏幕截图中选择的面板。这是我的屏幕截图,显示您需要在编译面板下拉列表中为应用程序和测试执行选择 默认为仅用于测试执行

Edit: Notice that the instruction above is pointing you to the Compile panel as opposed to the Run panel that you have selected in your screenshot. Here's my screen shot showing that you need to choose for both application and test execution in the Compile panel drop down and that the default is for test execution only

这篇关于立即重新部署Java EE应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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