# Spring 图

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

> **TL;DR**
> 必需插件：  Spring  和  Diagrams （捆绑）

Spring 图表可以帮助您分析应用程序中的依赖关系。 您可以双击图上的 bean 或文件，在编辑器中将其打开到专用选项卡。

> **Tip:**
> 对于 Spring Boot，您还可以构建 [Runtime Beans 图](spring-boot.html#endpoints-beans)。

## Spring Beans 依赖关系图

请使用   Spring Bean 依赖关系   图表查看和分析项目中 bean 之间的依赖关系。

Procedure: 打开图表

1. 在注释区中，点击 ![](https://resources.jetbrains.com.cn/help/img/idea/2026.3/spring.icons.expui.gutter.springBean%4014x14.svg)豆子图标（适用于 Java 或 Kotlin 文件）或点击 ![Spring diagram 图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/spring.icons.expui.gutter.springDiagrams%4014x14.svg)图表图标（适用于 XML 文件）。

![Spring 槽图标操作](https://resources.jetbrains.com.cn/help/img/idea/2026.3/spring_gutter_icon_actions.png)

2. 选择   Bean 依赖关系图  。

或者，右键点击文件，然后从上下文菜单中选择  `图表｜显示图表｜Spring Beans 依赖关系图谱`  `Ctrl+Alt+Shift+U` (Windows), `⌘ ⌥ ⇧ U` (macOS), `⌘ ⌥ ⇧ U` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ ⇧ U` (macOS System Shortcuts), `Ctrl+Alt+Shift+U` (XWin), `Ctrl+Alt+Shift+U` (GNOME), `Ctrl+Alt+Shift+U` (KDE), `Ctrl+Alt+Shift+U` (Emacs), `Ctrl+Alt+Shift+U` (Sublime Text), `⌘ ⌥ ⇧ U` (Sublime Text (macOS)), `Ctrl+Alt+Shift+U` (Visual Studio), `⌘ ⌥ ⇧ U` (Visual Studio (macOS)), `Ctrl+Alt+Shift+U` (NetBeans), `Ctrl+Alt+Shift+U` (Eclipse), `⌘ ⌥ ⇧ U` (Eclipse (macOS))。

![Spring Beans 依赖关系图](https://resources.jetbrains.com.cn/help/img/idea/2026.3/beans-dependencies.png)

此操作将在单独的编辑器选项卡中打开图表。 要在弹出窗口中打开它，右键点击文件并选择   图表 | 显示图表弹出窗口   `Ctrl+Alt+U` (Windows), `⌘ ⌥ U` (macOS), `⌘ ⌥ U` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ U` (macOS System Shortcuts), `Ctrl+Alt+U` (XWin), `Ctrl+Alt+U` (GNOME), `Ctrl+Alt+U` (KDE), `Ctrl+Alt+U` (Emacs), `Ctrl+Alt+U` (Sublime Text), `⌘ ⌥ U` (Sublime Text (macOS)), `Ctrl+Alt+U` (Visual Studio), `⌘ ⌥ U` (Visual Studio (macOS)), `Ctrl+Alt+U` (NetBeans), `Ctrl+Alt+U` (Eclipse), `⌘ ⌥ U` (Eclipse (macOS))。

您还可以通过点击 ![Spring diagram 图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/spring.icons.expui.springDiagrams.svg) 的图标访问 bean 依赖关系图在 [Spring工具窗口](spring-tool-window.html) 中。

要在图表上查看 bean 的直接依赖关系，请点击图表工具栏中的 ![邻域模式图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.graph.nodeSelectionMode.svg) (   显示所选节点的邻居节点  )。

若要在图表上显示库 bean，请点击图表工具栏中的 ![库图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app-client.expui.nodes.library.svg) (   显示库中的 bean  )。

## Spring Context Dependencies 图表

使用   Spring 上下文依赖关系  图表查看多个配置文件之间的依赖关系，并分析它们如何包含和引用彼此。 图中红色箭头标记了错误（如循环依赖），以便您轻松发现并从 Spring 配置中删除它们。

Procedure: 打开图表

1. 右键点击您要为其构建图表的配置文件。

2. 在上下文菜单中，选择   图表 | 显示图表   `Ctrl+Alt+Shift+U` (Windows), `⌘ ⌥ ⇧ U` (macOS), `⌘ ⌥ ⇧ U` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ ⇧ U` (macOS System Shortcuts), `Ctrl+Alt+Shift+U` (XWin), `Ctrl+Alt+Shift+U` (GNOME), `Ctrl+Alt+Shift+U` (KDE), `Ctrl+Alt+Shift+U` (Emacs), `Ctrl+Alt+Shift+U` (Sublime Text), `⌘ ⌥ ⇧ U` (Sublime Text (macOS)), `Ctrl+Alt+Shift+U` (Visual Studio), `⌘ ⌥ ⇧ U` (Visual Studio (macOS)), `Ctrl+Alt+Shift+U` (NetBeans), `Ctrl+Alt+Shift+U` (Eclipse), `⌘ ⌥ ⇧ U` (Eclipse (macOS))。

此操作将在单独的编辑器选项卡中打开图表。 要在弹出窗口中打开它，请选择   图表 | 显示图表弹出窗口   `Ctrl+Alt+U` (Windows), `⌘ ⌥ U` (macOS), `⌘ ⌥ U` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ U` (macOS System Shortcuts), `Ctrl+Alt+U` (XWin), `Ctrl+Alt+U` (GNOME), `Ctrl+Alt+U` (KDE), `Ctrl+Alt+U` (Emacs), `Ctrl+Alt+U` (Sublime Text), `⌘ ⌥ U` (Sublime Text (macOS)), `Ctrl+Alt+U` (Visual Studio), `⌘ ⌥ U` (Visual Studio (macOS)), `Ctrl+Alt+U` (NetBeans), `Ctrl+Alt+U` (Eclipse), `⌘ ⌥ U` (Eclipse (macOS))。

3. 在   选择图表类型  弹出菜单中，点击 ![Spring Context Dependencies 图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/spring.icons.springDiagrams.svg)   Spring 上下文依赖关系  。

![Spring Context Dependencies 图表](https://resources.jetbrains.com.cn/help/img/idea/2026.3/model-dependencies.png)

Spring 上下文依赖关系图使用以下箭头：

|  ![实心蓝色箭头](https://resources.jetbrains.com.cn/help/img/idea/2026.3/spring_graph_componentScan_dependency.png)  |  一条实线蓝线表示  `@ComponentScan` 注解依赖。  |
|  ![实心黄色箭头](https://resources.jetbrains.com.cn/help/img/idea/2026.3/spring_graph_enable_dependency.png)  |  黄色实线代表  `@Enable` 注解依赖。  |
|  ![虚线绿色箭头](https://resources.jetbrains.com.cn/help/img/idea/2026.3/spring_grapgh_import_dependency.png)  |  绿色虚线表示  `@Import` 注解依赖。  |
|  ![灰色虚线箭头](https://resources.jetbrains.com.cn/help/img/idea/2026.3/spring_graph_other_dependency.png)  |  虚线灰线代表其他依赖项。  |
|  ![红色虚线箭头](https://resources.jetbrains.com.cn/help/img/idea/2026.3/spring_graph_error_dependency.png) ![实心红色箭头](https://resources.jetbrains.com.cn/help/img/idea/2026.3/spring_graph_error2_dependency.png)  |  红线代表错误。  |

