【问题标题】:Spring boot project is spring boot test initialisation errorspring boot项目是spring boot测试初始化​​错误
【发布时间】:2019-05-30 02:01:12
【问题描述】:

我的 Spring Boot 项目显示构建失败并出现以下错误

-------------------------------------------------- ----------------------------------------- 测试集:com.examples.springbootdemo.SpringbootDemoApplicationTests -------------------------------------------------- ----------------------------------------- 测试运行:1,失败:0,错误:1,跳过:0,经过的时间:0.055 s

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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example2</groupId>
    <artifactId>spring-hello</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>spring-hello</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </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>

【问题讨论】:

  • Kunwar 你的问题不够解释!
  • 发布您的测试课程并解释整个问题。
  • 看起来缺少测试范围的运行时依赖项。请将 pom.xml/build.gradle/etc 添加到您的问题中。

标签: spring-boot


【解决方案1】:

在你的 pom 中添加 JUnit 依赖。

 <dependency> 
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version> 
</dependency>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-16
    • 1970-01-01
    • 2016-11-10
    • 2018-02-14
    • 1970-01-01
    • 2017-09-06
    • 1970-01-01
    相关资源
    最近更新 更多