Redeployment and Live Reload
在开发过程中,webforJ 将保存的更改应用到运行中的应用程序并更新浏览器。类更改通过 hotswap tool 或通过重启到达应用。实时重载会在任一操作后更新浏览器。
从 archetype 创建的项目已经配置完成。对于现有项目,请按照 Spring Boot 或 Jetty 进行操作。
每个更改的应用方式
| 更改 | 结果 | 参考 |
|---|---|---|
| Java 类,已连接 hotswap 工具 | 类在运行中的应用程序中更新。页面的受影响部分重建,应用程序状态保持不变。 | Hotswap |
| Java 类,无 hotswap 工具 | 应用程序重新启动。当应用准备好时,浏览器重新加载。 | Spring Boot, Jetty |
| 样式表或图像 | 页面在原地应用更改,无需重新加载。 | Settings |
src/main/frontend 下的源代码 | 监视器重建并更新浏览器。 | Frontend watch |
设置
这些设置控制开发过程中的实时重载:
| 属性 | 默认值 | 描述 |
|---|---|---|
webforj.devtools.livereload.enabled | false | 在开发运行中开启实时重载。 |
webforj.devtools.livereload.websocket-port | 35730 | 浏览器连接的端口。 |
webforj.devtools.livereload.websocket-path | /webforj-devtools-ws | 浏览器连接的路径。 |
webforj.devtools.livereload.static-resources-enabled | true | 在原地应用样式表和图像更改,而不是重新加载页面。 |
webforj.devtools.livereload.heartbeat-interval | 30000 | 用于连接检查的毫秒间隔,以检测重启的服务器。 |
这些键在打包的应用程序中没有效果。打包的应用程序不包含开发工具。
主题
Hotswap
Apply compiled class changes to a running webforJ app without a restart, through HotswapAgent or JRebel configured in the webforJ build plugin.
Frontend watch
Rebuild the sources under src/main/frontend while a webforJ app runs, applying stylesheet and image output in place and reloading the view for script output.
Spring Boot
Set up live reload in a Spring Boot webforJ app, with the development tools delivered by the webforJ build plugin.
Jetty
Run a webforJ app on the embedded Jetty server with the Maven Jetty plugin, with live reload and hotswap during development.