本文介绍了springframework.security包未找到启动器安全性依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的项目使用 spring boot spring starter dependencies
我尝试了 Gradle 中的spring starter安全依赖项,但只有项目中没有找到安全包。 IDE是 IntelliJ IDEA



我的 build.gradle 文件:

  buildscript {
ext {
springBootVersion ='1.2.7.RELEASE'
}
存储库{
mavenCentral()
}
依赖项{
classpath(org.springframework.boot:spring-boot-gradle-plugin:$ {springBootVersion})
classpath('io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE')
classpath(org.springframework:springloaded:1.2.4.RELEASE)
}
}

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

jar {
baseName ='hashfon-spring'
version ='0.0.1-SNAPSHOT '
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

知识库{
mavenCentral()



依赖关系{
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile(' org.springframework.boot:spring-boot-starter-data-rest')
compile('org.springframework.boot:spring-boot-starter-hateoas')
compile('org.springframework。 boot:spring-boot-starter-jersey')
compile('org.springframework.boot:spring-boot-starter-mustache')
compile('org.springframework.boot:spring-boot- ('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-security')

runtime('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
}

除安全外的所有库都可以在 外部库 中找到。 .. $ / $>

项目中类的一个例子:

  import org.springframework.context.annotation.Configuration; 
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web。*;
import org.springframework.hateoas。*;
import org.springframework.mock。*;
import org.springframework.data。*;
import org.springframework.security。*; //无法解析符号!
/ **
*我可以从外部库中导入所有包,除了安全性
* /

PS。我尝试了很多不同版本的 spring-security-core ,但没有任何反应。

解决方案

多次处理这个问题后,我遇到了以下解决方案,这对我来说是100%:


  1. 转到文件|使缓存无效

  2. 删除UNIX系统中存储所有依赖项的文件夹( 〜/ .gradle / ) - if它在失效后存在

  3. 重新启动Intellij IDEA

  4. 通过刷新gradle重新导入gradle依赖关系:


I'm using spring boot and spring starter dependencies for my project. I tried with spring starter security dependency in Gradle, but only security packages are not found in project. IDE is IntelliJ IDEA‎.

My build.gradle file :

buildscript {
    ext {
        springBootVersion = '1.2.7.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
        classpath('io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE')
        classpath("org.springframework:springloaded:1.2.4.RELEASE")
    }
}

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

jar {
    baseName = 'hashfon-spring'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-data-rest')
    compile('org.springframework.boot:spring-boot-starter-hateoas')
    compile('org.springframework.boot:spring-boot-starter-jersey')
    compile('org.springframework.boot:spring-boot-starter-mustache')
    compile('org.springframework.boot:spring-boot-starter-thymeleaf')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-security')

    runtime('mysql:mysql-connector-java')
    testCompile('org.springframework.boot:spring-boot-starter-test') 
}

All libraries except security can be found in External Libraries...

One example of class in project:

import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.*;
import org.springframework.hateoas.*;
import org.springframework.mock.*;
import org.springframework.data.*;
import org.springframework.security.*;  //cannot resolve symbol!
/**
 * I can import all packages from external libraries except security
 */

PS. I tried with a lot of different release versions of spring-security-core and nothing happens.

After dealing with this issue multiple times I came across following solution which works for me 100%:

  1. Go to File | Invalidate Caches
  2. Delete folder where all dependencies are stored (~/.gradle/ for UNIX systems) - if it exists after invalidation
  3. Restart Intellij IDEA
  4. Reimport gradle dependencies by refreshing gradle:

这篇关于springframework.security包未找到启动器安全性依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!