简体   繁体   English

如何在eclipse中将源附加到Web App库?

[英]How to attach source to a Web App Libraries in eclipse?

Is there a way to attach source to a web app library in eclipse 3.5/3.6? 在Eclipse 3.5 / 3.6中,是否可以将源附加到Web应用程序库? What I have tried: 我试过的

  1. Till eclipse 3.3, I could attach source to jars inside the web app library, though individually. 直到eclipse 3.3,我仍可以将源代码附加到Web应用程序库中的jar中,尽管是单独的。 Now attaching source to jars inside a web app library does not work. 现在,将源附加到Web应用程序库内的jar上无效。

  2. 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. 可以包含外部jar,甚至可以再次包含Web应用程序库中的jar,并且可以附加源,并且可以正常工作。

  3. Adding source paths to classpath.decorations.xml and .classpath files works for jars but not for the web app library. 将源路径添加到classpath.decorations.xml和.classpath文件适用于jar,但不适用于Web应用程序库。

  4. 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. 甚至对图书馆也这样尝试过: <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container" sourcepath="<source path>"/>在罐子的同一行,不起作用,当我重新启动Eclipse时被覆盖,删除了sourcepath。

Now how do I assign sources to a web app library? 现在如何将源分配给Web应用程序库?

(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..!) (顺便说一句,解决方法是在外部包括jar,而不是Web应用程序库,但繁琐和使用Web应用程序库的原因..!)

The server adapter needs to provide it. 服务器适配器需要提供它。 Unfortunately they rarely do. 不幸的是,他们很少这样做。

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\\ . 通过反复试验,我发现可以使用同一文件:classpath.decorations.xml来完成3.3-3.7中的源附件,该文件可以在以下位置找到:.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. 但是在各种版本的Eclipse中传递路径的方式有所不同。

for 3.3, it requires the path relative to the workspace location. 对于3.3,它需要相对于工作区位置的路径。 for 3.5-3.7, eclipse requires the path to be absolute path, like starting with drive name.. (not sure about 3.4) 对于3.5-3.7,eclipse要求路径必须是绝对路径,例如以驱动器名称开头。(不确定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. 这是从UI添加源时更新的同一文件,但是如果不起作用,则也可以手动修改该文件。 Reopen the workspace for the changes to reflect. 重新打开工作区以反映更改。

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. 包资源管理器中Web应用程序库树下的单个jar文件的属性中提供了设置Java源附件的选项。 It is there in eclipse galileo but not sure about eclipse 3.6 它在日食伽利略中存在,但不确定日食3.6

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

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