使用 IntelliJ IDEA 直接跳转到 Mapper 文件的方法:鼠标悬停在目标实体类上;选择 "Go to" 选项;展开 "SQL Mappings" 部分;选中与实体类对应的 Mapper 文件;按回车键。

如何直接从 IntelliJ IDEA 跳到 Mapper 文件
IntelliJ IDEA 为 Java 开发提供了许多方便快捷的功能,包括直接跳转到 Mapper 文件。
步骤:
-
定位目标实体类:在 Java 文件中,找到要操作的实体类,例如:
User.java。 - 鼠标悬停在类名上:将鼠标悬停在实体类名上,即可看到一个弹出菜单。
- 选择 "Go to":从弹出菜单中,选择 "Go to" 选项。
- 选择 "SQL Mappings":在 "Go to" 对话框中,展开 "SQL Mappings" 部分。
-
选中 Mapper 文件:选中与实体类对应的 Mapper 文件,例如:
UserMapper.xml。 - 按回车键:按回车键即可直接跳转到 Mapper 文件。
示例:
假设我们有一个 User 实体类,并且有相应的 UserMapper Mapper 文件。要从 IntelliJ IDEA 直接跳转到 Mapper 文件,请执行以下操作:
- 将鼠标悬停在
User.java文件中的User类名上。 - 在弹出菜单中,选择 "Go to"。
- 展开 "SQL Mappings" 部分。
- 选中
UserMapper.xml文件。 - 按回车键。
IntelliJ IDEA 将直接跳转到 UserMapper.xml Mapper 文件,您可以查看和编辑其中的 SQL 语句。










