gpt4 book ai didi

spring - 如何在IntelliJ中使用gradle添加spring-security-dependency?

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

我想使用依赖项:implementation '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,请在此处找到一个选项:

IntelliJ Offline Toggle

对于旧版本:

  • 首选项
  • 进入Build,Execution,Deployment。
  • 最后选择Gradle。
  • 取消选中离线工作。单击“应用”,然后单击“确定”。

  • 希望这会起作用。

    关于spring - 如何在IntelliJ中使用gradle添加spring-security-dependency?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62009906/

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