maven - 为什么 maven 在错误的 repo 中寻找 Artifact ?

标签 maven jetty maven-3

我在 pom.xml 中定义了一个依赖项在 Maven 3 项目中。依赖如下:

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>el-impl</artifactId>
    <scope>runtime</scope>
    <version>2.2</version>
</dependency>

Repository 在 pom 中的描述如下:
<repository>
    <id>java.net</id>
    <name>java.net</name>
    <url>http://download.java.net/maven/2</url>
</repository>

Artifact 确实存在于存储库中。 It's easy to check .尽管如此,Maven 正试图从 repo1.maven.org 获取 Artifact 。 . 这可能是什么原因? 也许我在定义存储库访问时犯了一些重大错误?其他依赖项似乎做得很好。
Plugin org.mortbay.jetty:maven-jetty-plugin:6.1.26 or one of its 
dependencies could not be resolved: Could not find artifact 
org.glassfish.web:el-impl:jar:2.2 
in central (http://repo1.maven.org/maven2)

最佳答案

repository您定义的用于依赖项,但 不是 plugins .因此错误。

为了解决这个问题,您需要定义 pluginRepositories :

<project>
    <!-- ... -->

    <pluginRepositories>
        <pluginRepository>
            <id>{repo.id}</id>
            <url>{repo.url}</url>
        </pluginRepository>
    </pluginRepositories>
</project>

至于你应该在哪里指定 - 在 pom.xml 或 settings.xml 中,阅读 this SO post .

关于maven - 为什么 maven 在错误的 repo 中寻找 Artifact ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6222175/

相关文章:

java - 将包与 Maven 一起使用

java - 使用 War 在 Spring、Hibernate 和 Jersey api 中嵌入 Jetty

java - 嵌入式 jetty : Servlet not initialized

java - 更新jdk版本后我现有的项目编译错误

maven-2 - 如何在 Maven 插件配置中保留空格?

java - 为什么通过 Maven copy-resources 插件进行复制操作后文件会变大?

tomcat - Artifactory 和 tomcat 内存不足

java - 在 Maven 中将本地 Jar 添加到父模块

eclipse - Google App Engine - Java 8 和 JSP 文件 : compilation error

java - 构建和配置文件标签中的 Maven antrun 插件