gpt4 book ai didi

spring-boot - Spring-Boot入门测试导入未解决

转载 作者:行者123 更新时间:2023-12-03 03:58:36 24 4
gpt4 key购买 nike

import org.springframework.test.context.junit4.SpringRunner;

测试包无法解析
Spring Boot版本2.0.3
Gradle 4.6版
JDK 1.8

我正在使用IntelliJ社区版IDE,并且我的操作系统是ubuntu-16.04

也尝试过:
1导入springframework.boot.test,但这也不起作用
2-导航到项目目录并使用终端构建项目

我不希望手动导入库。

Gradle脚本:
    buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.3.RELEASE")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

bootJar {
baseName = 'gs-spring-boot'
version = '0.1.0'
}

repositories {
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("junit:junit")
testCompile("org.springframework.boot:spring-boot-starter-test")
}

最佳答案

声明:testCompile("junit:junit"),不需要

依赖关系:

testCompile('org.springframework.boot:spring-boot-starter-test')

解决以下类(class):
import org.springframework.test.context.junit4.SpringRunner;

关于spring-boot - Spring-Boot入门测试导入未解决,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51440184/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com