# 在应用程序服务器上更新应用程序

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/idea/llms.txt).

> **TL;DR**
> 所需插件： [Jakarta EE: 应用程序服务器](https://plugins.jetbrains.com/plugin/20203)（已捆绑）和 [特定服务器插件](application-servers-support.html)

如果需要在应用程序服务器上运行时修改应用程序的源代码，每次应用更改都重启服务器通常不是一个实际的解决方案。 为方便审查更改，IntelliJ IDEA 提供多个 [更新策略](#application-server-update-policies)，可让你控制在触发应用程序更新时应用程序的重载范围。

Procedure: 更新正在运行的应用程序

只能在 [应用程序服务器运行配置](creating-run-debug-configuration-for-application-server.html) 处于运行状态时，无论是常规模式还是调试模式，才能触发应用程序更新。

1. 通过以下任一方式打开   更新   对话框：

* 按下 `Ctrl+F10` (Windows), `⌘ F10` (macOS), `⌘ F10` (IntelliJ IDEA Classic (macOS)), `⌘ F10` (macOS System Shortcuts), `Ctrl+F10` (XWin), `Ctrl+F10` (GNOME), `Ctrl+F10` (KDE), `Ctrl+F10` (Emacs), `Ctrl+F10` (Sublime Text), `⌘ F10` (Sublime Text (macOS)), `Ctrl+F10` (Visual Studio), `⌘ F10` (Visual Studio (macOS)), `Ctrl+F10` (NetBeans), `Ctrl+F10` (Eclipse), `⌘ F10` (Eclipse (macOS))。

* 在主菜单中，前往 `运行｜调试操作｜更新应用程序` 。

* 在主工具栏的 [运行微件](guided-tour-around-the-user-interface.html#toolbar) 中，点击 ![重新运行图标](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.run.rerun.svg) 重新运行 或 ![重启调试图标](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.run.restartDebug.svg) 重新启动调试 。

* 在 [服务](services-tool-window.html) 工具窗口（ `Alt+8` (Windows), `⌘ 8` (macOS), `⌘ 8` (IntelliJ IDEA Classic (macOS)), `⌘ 8` (macOS System Shortcuts), `Alt+8` (XWin), `Alt+8` (GNOME), `Alt+8` (KDE), `Alt+8` (Emacs), `Alt+8` (Sublime Text), `⌘ 8` (Sublime Text (macOS)), `Alt+8` (Visual Studio), `Alt+8` (Visual Studio (macOS)), `Alt+8` (NetBeans), `Alt+8` (Eclipse), `⌘ 8` (Eclipse (macOS))）中，点击 ![更新应用程序图标](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.javaee.updateRunningApplication.svg) 更新应用程序 。

> **Note:**
> 如果在运行配置中清除了   显示对话框   选项，则不会出现此对话框。 如需了解该选项的更多信息，请参阅 [设置默认应用程序更新策略](#specify-application-server-update-policies)。

2. 在对话框中，选择一个 [更新策略](#application-server-update-policies)，然后点击   OK  。

Procedure: 设置默认应用程序更新策略

可以在应用程序的 [应用程序服务器运行配置](creating-run-debug-configuration-for-application-server.html) 中设置默认 [更新策略](#application-server-update-policies)。

1. 打开   运行/调试配置  对话框：

* 在主工具栏，点击 [运行微件](guided-tour-around-the-user-interface.html#toolbar)并选择 编辑配置… 。

* 或者，转到 `运行 | 编辑配置…` 。

2. 在对话框左侧，选择应用程序服务器运行配置。

3. 在对话框右侧，配置以下字段：

* 执行“更新”操作时 ：选择在你 [触发应用程序更新](#update)时，IDE 应该运行哪种更新策略。

* 显示对话框 : * 如需在每次触发更新时让 IDE 显示带有可用更新策略的对话框，请选择此选项。 * 如果想跳过对话框并自动运行 执行“更新”操作时 字段中设置的策略，请取消选中此选项。 > **Note:** > 取消勾选此选项不会影响运行微件中的 ![重新运行图标](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.run.rerun.svg) 重新运行 和 ![重启调试图标](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.run.restartDebug.svg) 重新启动调试 按钮。 每次点击它们时，IDE 都会显示带有可用更新策略的对话框。

* 框架停用时 ：选择当你从 IntelliJ IDEA 切换到其他窗口（例如 Web 浏览器）时 IDE 应运行哪个更新策略。

4. 点击   应用  ，然后   OK  。

## 可用的应用程序更新策略

本章节介绍 IntelliJ IDEA 支持的所有在应用程序服务器上运行的应用程序的更新策略。 可用策略取决于你的运行配置类型（本地或远程）和工件类型（分解或软件包）。 某些策略仅在 [调试模式](starting-the-debugger-session.html)下可用。

本地运行配置:

|  更新策略  |  描述  |  工件类型  |
| --- | --- | --- |
|    更新资源    |  更新工件目录中修改过的资源（如 HTML、JSP、JavaScript、CSS 或图片）。  |  分解  |
|    更新类和资源    |     重新编译工件中包含的模块，并更新工件目录中修改过的资源和类（包括 EJB、servlet 等）。       如果应用程序处于调试模式，IntelliJ IDEA 会对类使用 [HotSwap](altering-the-program-s-execution-flow.html#reload_classes)，并将其在 JVM 中更新，而不是更新工件目录。     |  分解  |
|    热替换类  （仅限调试模式）  |     重新编译工件中包含的模块，并使用 HotSwap 在 JVM 中更新已修改的类。     |     软件包     |
|    重新部署    |     重新构建应用程序工件并重新部署到服务器。       此策略可能耗时。     |  分解及软件包  |
|    重启服务器    |     重启服务器，重新构建应用程序工件，并重新部署到服务器。       此策略可能非常耗时。     |  分解及软件包  |

远程运行配置:

|  更新策略  |  描述  |  工件类型  |
| --- | --- | --- |
|    热替换类  （仅限调试模式）  |     重新编译工件中包含的模块，并使用 [HotSwap](altering-the-program-s-execution-flow.html#reload_classes) 在 JVM 中更新已修改的类。     |     分解及软件包     |
|    重新部署    |     重新构建应用程序工件并重新部署到服务器。       此策略可能耗时。     |  分解及软件包  |

## See also

### 概念

[应用程序服务器](application-servers-support.html) [工件参考](artifacts.html) [运行/调试配置](run-debug-configuration.html)

### 操作指南

[Define application servers](configuring-and-managing-application-server-integration.html) [Create application server run configurations](creating-run-debug-configuration-for-application-server.html) [运行应用程序](running-applications.html) [调试代码](debugging-code.html)

