问题
I'd like to use the source code of maven-managed dependencies when debugging our webapp in myEclipse 8.
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.
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 ...
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 ...
回答1:
Looks like issue 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.
回答2:
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.
回答3:
Please do the following steps in Eclipse IDE(Tested with Version: 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.
Regards, Rajesh.
回答4:
Just put the .m2/repository/ folder itself with the search subfolders option.
来源:https://stackoverflow.com/questions/1808651/eclipse-debugger-attaching-source-code-of-maven-dependencies