简体   繁体   English

Eclipse不在Maven下载的jar文件中搜索文件

[英]Eclipse does not search for files in Maven downloaded jar files

I am working in a Spring project with loads of maven dependencies. 我正在一个带有Maven依赖项负载的Spring项目中工作。 That project, is importing some xml files in the ApplicationContext.xml. 该项目正在ApplicationContext.xml中导入一些xml文件。 For example: 例如:

<import resource="servers.xml" />

The project works fine, but I don't know in which jar file is that server.xml file. 该项目工作正常,但我不知道该server.xml文件位于哪个jar文件中。

I thought that with a resource search (Ctrl + Shift + R) I would be able to find it, but it looks like my Eclipse is not searching for regular files in the Maven downloaded jars. 我以为通过资源搜索(Ctrl + Shift + R)我可以找到它,但是看起来我的Eclipse不在Maven下载的jar中搜索常规文件。 Is it an error from my workspace? 我的工作空间有错误吗? Is there any way to search for xml files in dependency jars? 有什么方法可以在依赖项jar中搜索xml文件吗? Thanks for your help. 谢谢你的帮助。

Imported resource files used in Spring applicationContext.xml can be "linked" using STS (Spring Tool Suite). 可以使用STS(Spring工具套件)“链接” Spring applicationContext.xml中使用的导入资源文件。 For that, you have to enable support for <import /> elements. 为此,您必须启用对<import />元素的支持。 In order to do that 为了做到这一点

  • Right click in your project and click on properties 右键单击您的项目,然后单击属性
  • On the left, go to Spring->Beans Support 在左侧,转到Spring-> Beans Support
  • On "Config Files", click on "Enable support for <import /> element in configuration files 在“配置文件”上,单击“在配置文件中启用对<import />元素的支持”
  • On the same screen, press on the "Scan" button from the right.It will get all the config files in the project. 在同一屏幕上,单击右侧的“扫描”按钮。它将获取项目中的所有配置文件。

With that, you should be able to "go" to the imported resources(via Ctrl + click) and discover in which jar file are they located. 这样,您应该能够“转到”导入的资源(通过Ctrl +单击),并发现它们位于哪个jar文件中。

I know it is not a perfect solution, but at lease it works while looking explicitly with Spring resources files. 我知道这不是一个完美的解决方案,但至少可以在使用Spring资源文件明确查找时起作用。

Similar question : Eclipse: open declaration/resource for spring beans and contexts 类似的问题: Eclipse:为Spring Bean和上下文打开声明/资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM