gpt4 book ai didi

java - 使用 maven 下载 Jetty 源代码和 Javadoc jar 并将它们链接到 Eclipse 中的二进制 jar

转载 作者:行者123 更新时间:2023-12-04 05:50:09 25 4
gpt4 key购买 nike

我正在开发一个使用 Eclipse IDE (3.6) 用 Ja​​va (1.6) 编写的 Web 应用程序项目,并决定使用 Jetty (8.0.4) 作为 Web 服务器和 servlet 容器。我正在使用 maven (2) 进行依赖和构建管理。开始时,我决定编写一个简单的测试应用程序,以确保我的工作是端到端的。这工作正常,我能够启动服务器并创建一些简单的 servlet。但是,maven 没有下载源代码和 Javadoc jar,因此当鼠标悬停在方法名称或类上时,找不到文档。它只报告以下内容:

Open Declaration javax.servlet.http.HttpServletResponseNote: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.


我已经搜索了如何执行此操作,但我只能找到 this page在 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 的任何指示?

最佳答案

尝试使用以下 Maven 命令重新创建 Eclipse 项目:

mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true

另一种选择是更新您的 pom.xml:

<plugin>
<artifactId>org.eclipse.jetty</artifactId>
<version>${jettyVersion}</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>

这两种解决方案仅在源代码和 javadocs 提供给您从中下载的存储库时才有效。

对于您的情况(和您的版本),它应该可以工作,因为您可以找到 the sources.jar在 Jetty 存储库中。

关于java - 使用 maven 下载 Jetty 源代码和 Javadoc jar 并将它们链接到 Eclipse 中的二进制 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10167016/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com