[英]How to jump to Spring context XML file from Java Class in Eclipse
I well read the question How to find Spring XML definition from Java Class in Eclipse but it does not seem to answer similar question from me. 我很好地阅读了如何从Eclipse的Java类中查找Spring XML定义的问题,但是它似乎并没有回答我的类似问题。
I would like to jump from Java class in editor to the spring context xml file. 我想从编辑器中的Java类跳转到spring上下文xml文件。
If I highlighted a class declaration in editor, by pressing a shortcut key or clicking on some icon, it should open the corresponding spring context xml which have the bean initialization definition and jump to the line which initializes the bean "< bean id=... >". 如果我在编辑器中突出显示了一个类声明,请通过按快捷键或单击某个图标,它应打开具有bean初始化定义的相应spring上下文xml,并跳转到初始化bean“ <bean id =。”的行。 >”。 If I highlighted a set method in editor, it will do something similar but jump to where the property is set "< property name=method_name... >" 如果我在编辑器中突出显示set方法,它将执行类似的操作,但是会跳转到该属性设置为“ <property name = method_name ...>”的位置
I am using Eclipse Java EE IDE for Web Developers Indigo SR2. 我正在为Web开发人员Indigo SR2使用Eclipse Java EE IDE。 I have installed Spring IDE Developers and SpringSource. 我已经安装了Spring IDE Developers和SpringSource。 I have added Spring nature to the project, added context xml to the project property Spring Beans Support Config Files, and could see the "S" on file icon decorator of the context file and java class, but I could NOT find a way to jump from the Java class to the spring context xml. 我已将Spring性质添加到项目中,将上下文xml添加到了项目属性Spring Beans支持配置文件中,并且可以在上下文文件和Java类的文件图标装饰器上看到“ S”,但是我找不到跳转的方法从Java类到spring上下文xml。
My colleague is using IntelliJ and they could see a bean icon in their editor next to class declaration. 我的同事正在使用IntelliJ,他们可以在编辑器中的类声明旁边看到一个Bean图标。 I would hope to see something similar on Eclipse. 我希望在Eclipse上看到类似的东西。 Ideally, not only class level, but also next to set methods. 理想情况下,不仅是类级别,而且要紧接set方法。
Any advice will be much appreciated! 任何建议将不胜感激!
Thanks Gerry 谢谢格里
The desired action is provided by the Spring Tools (Spring Tool Suite), which can be installed the usual way, ie as Feature, or via the Eclipse Marketplace. 所需的操作由Spring Tools(Spring Tool Suite)提供,可以按通常的方式安装,即作为Feature或通过Eclipse Marketplace安装。
In Eclipse Mars, all of this will be setup automatically, when importing a Maven project and using the M2E plugin. 在Eclipse Mars中,当导入Maven项目并使用M2E插件时,所有这些都将自动设置。 Moreover, there is also a setting in the "Spring" tab, which allows to autodetect your Spring XML files. 此外,“ Spring”选项卡中还有一个设置,可以自动检测您的Spring XML文件。 Anyhow, the spring project configuration needs to parse and evaluate those XML files during the incremental build of your project. 无论如何,spring项目配置需要在项目的增量构建期间解析和评估那些XML文件。 So far for the prerequisites. 至此为前提条件。
The actual function is called " open spring bean " 实际功能称为“ 开放式弹簧豆 ”
By default, there is no keybinding for this operation, so either 默认情况下,此操作没有键绑定,因此
This function will give you a Eclipse typical quick-hover-and-search box, where you can start typing. 此功能将为您提供一个Eclipse典型的快速悬停和搜索框,您可以在其中开始键入。 If the cursor is on the class name of the bean implementation Java class, the view will be populated already and you just need to hit enter. 如果光标位于bean实现Java类的类名称上,则该视图将已被填充,您只需按Enter键。
<Rant>
This is such a crucial and basic feature. <Rant>
这是一个至关重要的基本功能。 Why the Spring and Eclipse folks are incapable to set up and document the very basics in a way easy to discover is beyond me. 为什么Spring和Eclipse的人无法以易于发现的方式来设置和记录基础知识,这超出了我的范围。 No wonder every idiot thinks that IntelliJ is vastly superior, which it is not. 难怪每个白痴都认为IntelliJ优越得多,事实并非如此。 In reality, both are on equal footing and have their strengths and weaknesses here and there. 实际上,两者都处于平等地位,并且在各处都有其优点和缺点。 </Rant>
I don't know if SpringSource or such have any specific keys for these, but good old Ctrl-shift-R (Navigate -> Open Resource) can be used to search for and open non-Java files in the workspace (like .xmls and .properties), for classes you can use Ctrl-shift-T (Navigate -> Open Type). 我不知道SpringSource或此类资源是否具有任何特定的键,但是可以使用旧的Ctrl-shift-R(导航->打开资源)来搜索和打开工作区中的非Java文件(例如.xmls)。和.properties),对于类,您可以使用Ctrl-shift-T(导航->打开类型)。 When the search window opens, just start typing file- or class name (you can also use wildcards like * and ?). 当搜索窗口打开时,只需开始输入文件名或类名(您也可以使用通配符,例如*和?)。
如果您使用的是Spring Tools Suite,请使用Alt+Shift+B
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.