eclipse 调试器:附加 Maven 依赖项的源代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1808651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
eclipse debugger: attaching source-code of maven dependencies?
提问by meriton
I'd like to use the source code of maven-managed dependencies when debugging our webapp in myEclipse 8.
在 myEclipse 8 中调试我们的 web 应用程序时,我想使用 maven 管理的依赖项的源代码。
I have managed to attach the sources to the libraries in the "Maven Managed Dependencies" classpath container, i.e. when I open a class file from a dependency (e.g. using Ctrl-Shift-T), I see the source code.
我设法将源代码附加到“Maven Managed Dependencies”类路径容器中的库,即当我从依赖项打开类文件时(例如使用 Ctrl-Shift-T),我看到了源代码。
However, when I define a server connector for my tomcat, deploy the wepapp to it, and launch it in debug mode and execution halts on a breakpoint in that same class, the editor pane only displays the text "source not found", and a button to edit the "source lookup path". I have attempted to manually add the "Maven Managed Dependencies" classpath container, only to be told "Use maven project settings to configure depedency resolution". However, I see no useful setting in that property pane ...
然而,当我为我的 tomcat 定义一个服务器连接器,将 wepapp 部署到它,并在调试模式下启动它并且执行在同一个类中的断点处停止时,编辑器窗格只显示文本“未找到源”,并且按钮来编辑“源查找路径”。我试图手动添加“Maven Managed Dependencies”类路径容器,但被告知“使用 Maven 项目设置来配置依赖解析”。但是,我在该属性窗格中看不到有用的设置...
How can I attach those sources? I am aware that this works with the m2e plugin and wtp, but I'd rather avoid convincing the rest of my team to switch plugins ...
我如何附加这些来源?我知道这适用于 m2e 插件和 wtp,但我宁愿避免说服我团队的其他成员切换插件......
采纳答案by meriton
I have since discovered that this problem only occurs if the server is launched using a launch configuration.
我后来发现只有在使用启动配置启动服务器时才会出现此问题。
The problem does not occur if the server is started by:
如果服务器是通过以下方式启动的,则不会出现此问题:
- click the server icon in the toolbar -> context menu appears
- mouse over the intended server -> submenu appears
- click on "Start"
- 单击工具栏中的服务器图标 -> 出现上下文菜单
- 将鼠标悬停在目标服务器上 -> 出现子菜单
- 点击“开始”
While this precludes sharing the server configuration by checking the launch configuration into version control, it at least allows seamless debugging.
虽然这排除了通过将启动配置检查到版本控制来共享服务器配置,但它至少允许无缝调试。
回答by VonC
Looks like issue MNGECLIPSE-983
看起来像问题MNGECLIPSE-983
I have confirmed that if I manually pick the External Archive option and find the relevant -sources jar (navigating that big
.m2/repository
tree to find it) and then add the jar as a sources it does work, and surprisingly it does remember the next time which isn't too bad.
That's at least doable I think for me because we don't often need to step debug through external dependencies, but when we do, it's often frequent, so adding it once while a bit of a pain, can be done on a case by case basis.
我已经确认,如果我手动选择 External Archive 选项并找到相关的 -sources jar(导航那
.m2/repository
棵大树以找到它),然后将 jar 添加为它确实可以工作的源,并且令人惊讶的是它会记住下次还不错。
我认为这至少是可行的,因为我们通常不需要通过外部依赖项进行逐步调试,但是当我们这样做时,它通常很频繁,因此添加一次虽然有点痛苦,但可以根据具体情况进行基础。
回答by Rajesh
Please do the following steps in Eclipse IDE(Tested with Version: 3.5.2),
请在 Eclipse IDE(测试版本:3.5.2)中执行以下步骤,
- In Package Explorer, Right Click on the Project which integrated with Maven container.
- Select Maven 2 and then select "Fetch Source JARs". The above action wil fetch sources of all the 3rd party jars present in the Maven Classpath.
- 在 Package Explorer 中,右键单击与 Maven 容器集成的项目。
- 选择 Maven 2,然后选择“Fetch Source JARs”。上述操作将获取 Maven 类路径中存在的所有 3rd 方 jar 的源。
Regards, Rajesh.
问候,拉杰什。
回答by user324168
Just put the .m2/repository/ folder itself with the search subfolders option.
只需将 .m2/repository/ 文件夹本身与搜索子文件夹选项一起放置。