The JAR file C:\…Tomcat-8.0\lib\servlet-api.jar has no source attachment

你说的曾经没有我的故事 提交于 2019-12-21 22:06:35

问题


I did Ctrl+Click on HttpServlet to see source code of HttpServlet, but it gave me this error:

How to fix this? It says, I should download "servlet-api.jar", but when I try to download, I can not understand which one should I download? There are lot of servlet-api.jar files.


回答1:


The source code is not necessarily specific to the Servlet API, but to the Servlet Implementation itself. In your particular case, Tomcat is the Servlet Implementation. So, you need to head to its homepage to find download links to the source code. Usually it's at the same place as where you downloaded the binaries.

Tomcat 8.0 download page is here, if you scroll to bottom, then you should see those links:

Binary Distributions

  • Core:
    • zip <-- this is Tomcat server itself.
    • ...

Source Code Distributions

  • ...
  • zip <-- this contains the source code.

Download the source code zip, put it somewhere in your file system (I usually put it in Tomcat installation folder; do note that you do not need to extract it!). Finally, press Attach Source button in Eclipse and point to that source code zip file.




回答2:


If this maven based project , you just select the dependency in the Package Explorer, right click and then select "Attach resource"



来源:https://stackoverflow.com/questions/35713815/the-jar-file-c-tomcat-8-0-lib-servlet-api-jar-has-no-source-attachment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!