简体   繁体   English

如何获取Eclipse + Maven以查找和使用Servlet API源代码或JavaDoc

[英]How to get eclipse+maven to find and use servlet api source code or javadoc

Recently, I downloaded the latest elcipse with everything in it, and added the sonatype maven plugin. 最近,我下载了包含所有内容的最新elcipse,并添加了sonatype maven插件。

We setup a number of servlet projects using the mavel eclipse plugin web archtypes to generate the poms etc. 我们使用mavel eclipse插件web原型创建了许多servlet项目,以生成poms等。

It adds: 它增加了:

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>servlet-api</artifactId>
  <version>2.4</version>
  <scope>provided</scope>
</dependency>    
<dependency>

However, it doesnt include the source or javadocs, so developing with this is a lot of groping in the dark and constant hunting of javadoc web pages. 但是,它不包括源代码或javadocs,因此用它进行开发在javadoc网页的黑暗和持续狩猎中有很多摸索。

I have scoured the maven website http://maven.apache.org/ , but cant find how to get it to include the source or javadoc as well as the actual dependant jar. 我已经搜索了Maven网站http://maven.apache.org/ ,但是找不到如何使其包含源代码或javadoc以及实际的依赖jar的方法。

I saw this article, but it doesnt have a solution: 我看到了这篇文章,但没有解决方案:

How to add Javadoc for Servlet API in Eclipse 如何在Eclipse中为Servlet API添加Javadoc

And this tip: http://tedwise.com/2010/01/27/maven-micro-tip-get-sources-and-javadocs/ but last time I used a mvn command outside of eclilpse, it destroyed the whole eclipse environment and I spent 2 days rebuiling it from scratch (now I know not to do that). 这个技巧: http ://tedwise.com/2010/01/27/maven-micro-tip-get-sources-and-javadocs/,但是上次我在eclilpse之外使用mvn命令时,它破坏了整个eclipse环境我花了2天的时间重新构建(现在我知道不这样做)。

Or do i have to manually add a jar of the source which exactly matches the java jar to ecilpse as source in the java build path? 还是我必须手动添加一个与Java jar完全匹配的源jar,以便将其作为java构建路径中的源? (ie not use maven). (即不使用Maven)。 I found a copy of the source here: http://mirrors.ibiblio.org/pub/mirrors/maven2/javax/servlet/servlet-api/2.4/ 我在这里找到了源的副本: http : //mirrors.ibiblio.org/pub/mirrors/maven2/javax/servlet/servlet-api/2.4/

Have you tried adding classifier inside dependency tags: 您是否尝试过在依赖项标签中添加分类器:

<classifier>sources</classifier>

OR changing Eclipse preferences: 或更改Eclipse首选项:

Eclipse > (Toolbar) > Window > Preferences > Maven:
Download Artifact JavaDoc
Download Artifact Source

(And then touch your pom file in Eclipse to make new Maven build.) (然后在Eclipse中触摸您的pom文件以建立新的Maven构建。)

Edit: source in classifier tag corrected to sources 编辑: source在分类标签修正为sources

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

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