我正在开发一个使用 Eclipse IDE (3.6) 用 Java (1.6) 编写的 Web 应用程序项目,并决定使用 Jetty (8.0.4) 作为 Web 服务器和 servlet 容器。我正在使用 maven (2) 进行依赖和构建管理。开始时,我决定编写一个简单的测试应用程序,以确保我的工作是端到端的。这工作正常,我能够启动服务器并创建一些简单的 servlet。但是,maven 没有下载源和 Javadoc jar,因此当鼠标悬停在方法名称或类上时,找不到文档。它只报告以下内容:
打开声明 javax.servlet.http.HttpServletResponse 注意:该元素既没有附加源也没有附加 Javadoc,因此找不到 Javadoc。
我已经搜索了如何做到这一点,我能找到的只是Eclipse 网站上的这个页面,该页面描述了如何配置 maven 来下载源模块。它表示源模块 jar 与二进制 jar 具有相同的名称,后缀为“-sources”。我为每个二进制模块添加了源模块依赖项到我的 Maven 配置中,如下所示:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jettyVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server-sources</artifactId>
<version>${jettyVersion}</version>
</dependency>
但是,maven 找不到源模块依赖:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Jetty Servlet Example 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-server-sources/8.0.4.v20111024/jetty-server-sources-8.0.4.v20111024.pom
[WARNING] The POM for org.eclipse.jetty:jetty-server-sources:jar:8.0.4.v20111024 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlet-sources/8.0.4.v20111024/jetty-servlet-sources-8.0.4.v20111024.pom
[WARNING] The POM for org.eclipse.jetty:jetty-servlet-sources:jar:8.0.4.v20111024 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util-sources/8.0.4.v20111024/jetty-util-sources-8.0.4.v20111024.pom
[WARNING] The POM for org.eclipse.jetty:jetty-util-sources:jar:8.0.4.v20111024 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-server-sources/8.0.4.v20111024/jetty-server-sources-8.0.4.v20111024.jar
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlet-sources/8.0.4.v20111024/jetty-servlet-sources-8.0.4.v20111024.jar
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util-sources/8.0.4.v20111024/jetty-util-sources-8.0.4.v20111024.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.098s
[INFO] Finished at: Sun Apr 15 15:42:59 PDT 2012
[INFO] Final Memory: 5M/180M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project hello-world: Could not resolve dependencies for project org.example:hello-world:jar:0.1-SNAPSHOT: The following artifacts could not be resolved: org.eclipse.jetty:jetty-server-sources:jar:8.0.4.v20111024, org.eclipse.jetty:jetty-servlet-sources:jar:8.0.4.v20111024, org.eclipse.jetty:jetty-util-sources:jar:8.0.4.v20111024: Could not find artifact org.eclipse.jetty:jetty-server-sources:jar:8.0.4.v20111024 in central (http://repo1.maven.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
有关如何配置 Maven 以下载 Jetty 源代码和 javadocs 的任何指示?