Eclipse Kepler 和 JBoss Wildfly 热部署

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20213032/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 21:58:49  来源:igfitidea点击:

Eclipse Kepler and JBoss Wildfly hot deployment

eclipseeclipse-keplerjboss-toolswildfly

提问by zulqarnain

I am trying to use eclipse kepler for Java EE 7.I already installed JBoss Tools and added JBoss Wildfly successfully as a server. However my changes are not automatically deployed. Is there anyway the app can be deployed automatically just as when using glassfish?

我正在尝试将 eclipse kepler 用于 Java EE 7。我已经安装了 JBoss Tools 并成功添加了 JBoss Wildfly 作为服务器。但是我的更改不会自动部署。无论如何,该应用程序是否可以像使用 glassfish 一样自动部署?

回答by varantes

Using Eclipse, click twice on your WildFly Server to edit the following properties:

使用 Eclipse,在 WildFly 服务器上单击两次以编辑以下属性:

  1. Publishing: choose "Automatically publish after a build event". I like to change the publishing interval to 1 second too.
  2. Application Reload Behavior: check the "Customize application reload ..." checkbox and edit the regex pattern to \.jar$|\.class$
  1. 发布:选择“在构建事件后自动发布”。我也喜欢将发布间隔更改为 1 秒。
  2. 应用程序重新加载行为:选中“自定义应用程序重新加载...”复选框并将正则表达式模式编辑为\.jar$|\.class$

That's it. Good luck!

就是这样。祝你好运!

回答by G. Demecki

Both @varantes and @Sean are essentially correct, but these answers are not full.

@varantes 和 @Sean 本质上都是正确的,但这些答案并不完整。

Unfortunately the only way in a Java server environment to have full, zero-downtime hot deployment is to use paid JRebelor free spring-loadedtool.

不幸的是,在 Java 服务器环境中实现完整、零停机热部署的唯一方法是使用付费的JRebel或免费的弹簧加载工具。

But for small project there are some ways to speed up work by partial hot-deployment. Essentially:

但是对于小型项目,有一些方法可以通过部分热部署来加快工作速度。本质上:

  1. When enabled option Automatically publish when resource changethen changes inside *.html, *.xhtmlfiles are immediately reflected as soon as you refresh the browser.
  2. To make hot deployment work for *.jspfiles too, then you should inside ${wildfly-home}/standalone/configuration/standalone.xmlmake following change:
    <jsp-config/>
    replace with:
    <jsp-config development="true"/>
  1. 当启用选项自动发布时资源更改然后在内部更改*.html*.xhtml刷新浏览器后立即反映文件。
  2. 为了使热部署也适用于*.jsp文件,您应该在${wildfly-home}/standalone/configuration/standalone.xml 中进行以下更改:
    <jsp-config/>
    替换为:
    <jsp-config development="true"/>

restart the server and enjoy hot deployment of web files.

重启服务器,享受网络文件的热部署。



But when modifying *.javasource files, then only partial hot deployment is possible. As @varantes stated in his answer, enabling Application Reload Behaviorwith regex pattern set to \.jar$|\.class$is an option, but has serious downside: whole module is restarted, thus:

但是在修改*.java源文件时,只能部分热部署。正如@varantes 在他的回答中所述,启用应用程序重新加载行为并将正则表达式模式设置为\.jar$|\.class$是一个选项,但有严重的缺点:整个模块重新启动,因此:

  1. It takes some time (depending on how big is a module).
  2. Whole application state is lost.
  1. 这需要一些时间(取决于模块的大小)。
  2. 整个应用程序状态丢失。

So personally, I discourage this solution. JVM supports (in debug mode) code-swapping for methods' bodies. So as long as you are modifying only bodies of existing methods, you are at home (zero downtime, changes are reflected immediately). But you have to disable automatic publishing inside server settings otherwise the application's state will still be destroyed by that republish.

所以就个人而言,我不鼓励这种解决方案。JVM 支持(在调试模式下)方法主体的代码交换。因此,只要您只修改现有方法的主体,您就可以轻松自如(零停机时间,更改会立即反映出来)。但是您必须在服务器设置中禁用自动发布,否则重新发布仍会破坏应用程序的状态。

But if you are heavily crafting Java code (adding classes, annotations, constructors) then unfortunately I can only recommend set publishing into Never publish automatically(or shutdown server) and when you finish your work in Java files, then restart by hand your module (or turn-on server). Up to you.

但是,如果您正在大量编写 Java 代码(添加类、注释、构造函数),那么不幸的是,我只能建议将发布设置为从不自动发布(或关闭服务器),并且当您在 Java 文件中完成工作时,然后手动重新启动您的模块(或打开服务器)。由你决定。



It works for small Java projects, but for bigger ones, JRebel is invaluable (or just spring-loaded), because all approaches described above are not sufficient. Also because of such problems, solutions like Rails/ Django /Play! Framework gained so huge popularity.

它适用于小型 Java 项目,但对于较大的项目,JRebel 是无价的(或只是弹簧加载),因为上述所有方法都不够。也是因为这样的问题,像Rails/Django/Play这样的解决方案!框架获得了如此巨大的人气。

回答by umphy

I am assuming you are using the latest version of Wildfly (8.0 Beta 1 as of writing).

我假设您使用的是最新版本的 Wildfly(撰写本文时为 8.0 Beta 1)。

In the standalone.xml config file, look for <jsp-config/>. Add the attribute development="true"and it should hot-deploy. The resulting config will look like this:

在 standalone.xml 配置文件中,查找<jsp-config/>。添加属性development="true"并且它应该热部署。生成的配置将如下所示:

<jsp-config development="true"/>

回答by PeterB

Add attributes (development, check-interval, modification-test-interval, recompile-on-fail) in configuration file in xPath = //servlet-container/jsp-config/

在 xPath 中的配置文件中添加属性(development、check-interval、modification-test-interval、recompile-on-fail)= //servlet-container/jsp-config/

<servlet-container name="default" default-buffer-cache="default" stack-trace-on-error="local-only">
    <jsp-config development="true" check-interval="1" modification-test-interval="1" recompile-on-fail="true"/>
</servlet-container>

(It works in WildFly-8.0.0.Final)

(它适用于 WildFly-8.0.0.Final)

回答by erickdeoliveiraleal

Start server in debug mode and It will track chances inside methods. Other changes It will ask to restart the server.

以调试模式启动服务器,它将跟踪方法内部的机会。其他更改 它将要求重新启动服务器。