【问题标题】:What dependency is missing from this Spring Boot Application?这个 Spring Boot 应用程序缺少什么依赖项?
【发布时间】:2018-01-10 18:13:06
【问题描述】:

我想创建一个带有 H2 数据库和 JPA 支持的 Spring Boot Web 应用程序。但 STS 在 pom.xml 概览中抛出错误: 缺少工件 org.springrfamework.boot:spring-boot-test.jar:1.5.6.RELASE(点击查看更多 49)

这是我的 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>data-demo-CS</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>demo</name>
    <description>Demo project for Spring Boot</description>

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

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </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>
    </dependencies>

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


</project>

【问题讨论】:

  • 你试过手动更新maven依赖吗?右键单击项目,然后在 maven 菜单下,选择更新项目。检查快照/发布选项的强制更新。然后构建项目。
  • “49 More”是怎么说的?
  • 您也可以通过命令行成功完成mvn clean install 吗?还是只是 Eclipse 的 STS 中的错误?
  • @amicoderozer 谢谢! Maven 更新解决了我的问题!

标签: spring spring-boot dependencies


【解决方案1】:

实际上,您的 ide 没有获得依赖项,您应该再次 clean build,如果仍然显示错误,则只需从本地存储库中删除该依赖项(即 ./.m2,如果使用 maven)和 clean build 您的项目然后所有必需的依赖项将再次下载到您的本地。

命令mvn clean compile package install

【讨论】:

    猜你喜欢
    • 2020-08-02
    • 1970-01-01
    • 2020-03-13
    • 2019-02-15
    • 2018-10-07
    • 2012-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多