我想使用依赖项:
实现“org.springframework.boot:spring-boot-starter-security”
在我的 IntelliJ 项目中,但出于某种原因,它无法解决此依赖性。
这些是我的依赖项。相关的是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')
}
出于某种原因,我在启动引导运行时收到此错误消息:
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)
}
最佳答案
您需要重新启用 Gradle 在线模式
对于最新版本的 IntelliJ IDE,请在此处查找选项:
对于旧版本:
- 偏好
- 进入构建、执行、部署内部。
- 最后选择 Gradle。
- 取消选中离线工作。单击“应用”,然后单击“确定”。
希望这会起作用。
关于spring - 如何在 IntelliJ 中使用 gradle 添加 spring-security-dependency ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62009906/