【问题标题】:Missing artifact when trying to add spring-data尝试添加弹簧数据时缺少工件
【发布时间】:2014-01-30 19:55:52
【问题描述】:

我正在尝试将 Spring 数据依赖项添加到我的 Spring Boot 启动项目中,但出现错误:Missing artifact org.springframework.data:spring-data-jdbc-ext:jar:1.0.0.RELEASE

这是我的 pom.xml 文件。我在这里错过了什么?

<?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>com.test</groupId>
  <artifactId>myApp</artifactId>
  <version>0.0.1-SNAPSHOT</version>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.0.0.RC1</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf-spring4</artifactId>
        </dependency>
            <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jdbc-ext</artifactId>
        <version>1.0.0.RELEASE</version>
    </dependency>
    </dependencies>

    <properties>
        <start-class>com.test.Application</start-class>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestone</id>
            <url>http://repo.spring.io/libs-milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-milestone</id>
            <url>http://repo.spring.io/libs-milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</project>

【问题讨论】:

  • 如果你浏览到those coordinates,你可以看到那里确实没有jar。它也不会出现在任何其他 Maven 搜索中。也许改用spring-data-jdbc-core

标签: spring maven spring-data


【解决方案1】:

由于某种原因,Spring Data JDBC Extensions 网站上的文档有误(或者分发有误!)。

根据该页面,您确实需要包含您提到的依赖项。

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jdbc-ext</artifactId>
    <version>1.0.0.RELEASE</version>
</dependency>

但是,如果您查看 the spring repository 中的那个工件,它包含一个带有发行版的 zip 文件,而不是一个 jar 或 pom 文件。

spring-data-jdbc-ext 项目由 2 个工件组成,两者都可用。将您的依赖项更改为以下

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jdbc-core</artifactId>
    <version>1.0.0.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-oracle</artifactId>
    <version>1.0.0.RELEASE</version>
</dependency>

如果您不需要特定的 Oracle 扩展,则可以将其省略。

还有一个 1.1.0.M1 版本(里程碑/预发布版本),它适用于较新版本的 Spring Data。您可能想尝试一下,而不是针对旧版本的 Spring Data 构建的 1.0.0.RELEASE 版本。

【讨论】:

  • Marten 的建议是正确的。 spring.io 网站中有一个错误,我们将纠正它。同时使用这里建议的依赖项。
猜你喜欢
  • 1970-01-01
  • 2017-05-15
  • 2011-12-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-28
  • 1970-01-01
  • 2017-08-08
相关资源
最近更新 更多