当搜索返回匹配时,无法在maven central repo中找到工件

Ram*_*Ram 12 maven-3

我试图在我的pom中引入对castor库的依赖.由于我的项目处于初步阶段,所有工件都来自maven central.所以我在search.maven.org上搜索"castor".我取第一个结果,它给了我以下依赖片段:

<dependency>
    <groupId>org.codehaus.castor</groupId>
    <artifactId>castor</artifactId>
    <version>1.3.3</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

现在我"mvn clean install"并获得以下内容:

[ERROR] Failed to execute goal on project jaxb: Could not resolve dependencies for project org.test:jaxb:war:0.0.1-SNAPSHOT: Could not find artifact org.codehaus.castor:castor:jar:1.3.3 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

为什么CLI无法找到可从Web界面找到的工件.我当然错过了一些东西.请求指出它可能是什么.

在其他帖子中,我已经调查了这个和这个相关的帖子,但不是这个问题.

我的完整pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.test</groupId>
<artifactId>jaxb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>jaxb</name>
<description>jaxb</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.1.9.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.moxy</artifactId>
        <version>2.6.0-M3</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-oxm</artifactId>
        <version>4.1.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.castor</groupId>
        <artifactId>castor</artifactId>
        <version>1.3.3</version>
    </dependency>

</dependencies>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <start-class>org.test.jaxb.Application</start-class>
    <java.version>1.7</java.version>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

khm*_*ise 14

您遇到的问题是您已定义为依赖项的工件:

<dependency>
    <groupId>org.codehaus.castor</groupId>
    <artifactId>castor</artifactId>
    <version>1.3.3</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

定义jar错误消息暗示的工件:org.codehaus.castor:castor:jar:1.3.3

问题是在Maven Central上不存在这种工件.它只存在pom文件而不是jar文件.

  • 谢谢@khmarbaise。这就说明了问题。作为后续:_only_ 暴露工件的 pom.xml 的目的是什么?对我而言,在存储库中发布工件的目的是让其他人使用它。是否可以仅通过使用其 pom 来依赖/重用工件? (3认同)
  • 这种工件的目的是基于产生工件的项目的性质.pom是发布到maven central的其他工件的父级.有些项目会阻止,有些则不会. (3认同)