我想在我的IntelliJ项目中使用dependency:implementation 'org.springframework.boot:spring-boot-starter-security'
,但是由于某种原因,它不能解决这个依赖。
这些是我的依赖项。与之相关的是spring-boot-starter-security
。
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
runtime('org.springframework.boot:spring-boot-devtools')
}
由于任何原因,我在启动boot-run时收到以下错误消息:
Error-message when starting boot-run
这里是整个build.gradle文件:
plugins {
id 'org.springframework.boot' version '2.2.7.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'de.hohenheim'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
runtime('org.springframework.boot:spring-boot-devtools')
}
test {
useJUnitPlatform()
}
bootRun {
sourceResources(sourceSets.main)
}
发布于 2020-05-26 05:04:03
您需要重新启用Gradle在线模式
有关最新版本的IntelliJ集成开发环境,请在此处找到一个选项:
对于旧版本:
选择
希望这能行得通。
发布于 2020-05-26 05:23:33
您似乎是在脱机模式下运行Gradle。在该模式下,Gradle将只使用其本地缓存。当您向项目添加新的依赖项时,Gradle将无法找到它。要修复此错误,请在Intellij中禁用脱机模式。
转到Gradle tool window并禁用此按钮:
它应该出现在工具栏(窗口顶部)中。如果它不可见(如下图所示),则当您放大窗口或单击工具栏最右侧的两个箭头(用蓝色标记)时,它应该会出现:
https://stackoverflow.com/questions/62009906
复制相似问题