如何在 Eclipse 中将源附加到 Web 应用程序库?
有没有办法将源附加到 Eclipse 3.5/3.6 中的 Web 应用程序库? 我尝试过的:
直到 eclipse 3.3,我可以将源代码附加到 Web 应用程序库内的 jar,尽管是单独的。 现在,将源代码附加到 Web 应用程序库内的 jar 不起作用。
可以包含外部 jar,甚至可以再次包含 Web 应用程序库中的 jar,并且可以附加源代码,并且它可以工作。
- 用于 Web 应用程序库。
甚至在库中尝试过这种方式:
在 jar 的同一行上,不起作用,当我重新启动 eclipse 时被覆盖,源路径被删除。
现在如何将源分配给网络应用程序库?
(顺便说一句,解决方法是在外部包含 jar,而不是 Web 应用程序库,但它很乏味,也是使用 Web 应用程序库的原因..!)
Is there a way to attach source to a web app library in eclipse 3.5/3.6?
What I have tried:
Till eclipse 3.3, I could attach source to jars inside the web app library, though individually.
Now attaching source to jars inside a web app library does not work.External jars can be included, or even a jar inside the web app library can be included again and source can be attached, and it works.
Adding source paths to classpath.decorations.xml and .classpath files works for jars but not for the web app library.
even tried it this way for a library:
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container" sourcepath="<source path>"/>
on the same lines of the jar, does not work, got overwritten when I restarted eclipse, sourcepath removed.
Now how do I assign sources to a web app library?
(BTW, the workaround is to include the jars externally, instead of web app library, but its tedious and the reason why the web app library is used..!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
服务器适配器需要提供它。不幸的是他们很少这样做。
The server adapter needs to provide it. Unfortunately they rarely do.
设置 java 源附件的选项位于包资源管理器中 Web 应用程序库树下的单个 jar 文件的属性中。它存在于 eclipse galileo 中,但不确定 eclipse 3.6
The option to set java source attachment is available in the properties for an individual jar file, under the web app libraries tree in package explorer. It is there in eclipse galileo but not sure about eclipse 3.6
通过反复试验,我发现 3.3-3.7 中的源附件可以使用相同的文件来完成: classpath.decorations.xml 可以在以下位置找到: .metadata.plugins\org.eclipse.jst.common.frameworks\ 。但是各个版本的eclipse的路径传递方式是有区别的。
对于 3.3,它需要相对于工作空间位置的路径。
对于 3.5-3.7,eclipse 要求路径为绝对路径,例如以驱动器名称开头。
(不确定 3.4)
这是从 UI 添加源时更新的文件,但如果这不起作用,您也可以手动修改该文件。重新打开工作区以使更改得以反映。
By trial and error I have found that source attachment in 3.3-3.7 can be done using the same file: classpath.decorations.xml which can be found at location: .metadata.plugins\org.eclipse.jst.common.frameworks\ . But there is a difference in how the path is to be passed for various versions of eclipse.
for 3.3, it requires the path relative to the workspace location.
for 3.5-3.7, eclipse requires the path to be absolute path, like starting with drive name..
(not sure about 3.4)
This is the same file that gets updated when sources are added from UI, but if that does not work, you can manually modify the file as well. Reopen the workspace for the changes to reflect.