[英]Hot code deployment in Jetty
I am writing a Java EE application, using Jetty as the app server for convenience during development. 我正在编写一个Java EE应用程序,在开发过程中使用Jetty作为应用程序服务器。 Although (re)deployment is fast, I'd like if it was possible for Java code changes to be reflected immediately in the running server without restarting. 虽然(重新)部署速度很快,但我希望Java代码更改能够立即反映在正在运行的服务器中,而无需重新启动。 (I'm already using the useFileMappedBuffer
setting to see immediate changes to statically served content). (我已经使用useFileMappedBuffer
设置来查看对静态服务内容的即时更改)。
I've seen questions about using the Maven Jetty plugin and setting scanInterval in order to redeploy a web context, but that's not what I want to do. 我已经看到有关使用Maven Jetty插件和设置scanInterval以重新部署Web上下文的问题,但这不是我想要做的。 My Jetty server is started from within a Java application in Eclipse and I'd like code changes to be immediately reflected in the running server, as is possible with ordinary Java applications in Eclipse. 我的Jetty服务器是从Eclipse中的Java应用程序启动的,我希望代码更改能够立即反映在正在运行的服务器中,就像Eclipse中的普通Java应用程序一样。 I'm running the code "in place", ie not building and deploying a WAR file first. 我正在运行“就地”代码,即不首先构建和部署WAR文件。
I realise that web apps have their own class loaders in order to conform to the servlet spec, but I don't mind risking non-standard behaviour to get changes deployed more rapidly in development. 我意识到Web应用程序有自己的类加载器,以符合servlet规范,但我不介意冒着非标准行为冒险在开发中更快地部署更改。 I've tried using WebAppContext.setClassLoader
to set the classloader to a "normal" classloader but to no avail. 我已经尝试使用WebAppContext.setClassLoader
将类加载器设置为“普通”类加载器,但无济于事。
Is it possible to do what I want? 有可能做我想要的吗? I believe JRebel claims to do it, but what's it doing that I'm not? 我相信JRebel声称要做到这一点,但它做了什么,我不是?
If you connect to Jetty using remote debug from Eclipse, Hot code replace should be possible. 如果使用Eclipse中的远程调试连接到Jetty,则应该可以进行热代码替换 。
Remote debugging is enabled by adding following to Jetty start script: 通过向Jetty启动脚本添加以下内容来启用远程调试:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787
Even the ordinary Java application needs to be restarted to see code changes. 甚至普通的Java应用程序也需要重新启动以查看代码更改。
Basically your options are: 基本上你的选择是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.