首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在IntelliJ中使用gradle添加spring-security-dependency?

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

Stack Overflow用户
提问于 2020-05-26 04:03:25
回答 2查看 1.7K关注 0票数 1

我想在我的IntelliJ项目中使用dependency:implementation 'org.springframework.boot:spring-boot-starter-security',但是由于某种原因,它不能解决这个依赖。

这些是我的依赖项。与之相关的是spring-boot-starter-security

代码语言:javascript
运行
复制
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文件:

代码语言:javascript
运行
复制
    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)
}
EN

回答 2

Stack Overflow用户

发布于 2020-05-26 05:04:03

您需要重新启用Gradle在线模式

有关最新版本的IntelliJ集成开发环境,请在此处找到一个选项:

对于旧版本:

选择

  1. Preferences
  2. Go inside Build,Execution,Deployment.
  3. Finally选择Gradle.
  4. uncheck offline work。单击apply,然后单击ok。

希望这能行得通。

票数 1
EN

Stack Overflow用户

发布于 2020-05-26 05:23:33

您似乎是在脱机模式下运行Gradle。在该模式下,Gradle将只使用其本地缓存。当您向项目添加新的依赖项时,Gradle将无法找到它。要修复此错误,请在Intellij中禁用脱机模式。

转到Gradle tool window并禁用此按钮:

它应该出现在工具栏(窗口顶部)中。如果它不可见(如下图所示),则当您放大窗口或单击工具栏最右侧的两个箭头(用蓝色标记)时,它应该会出现:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62009906

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档