Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 找不到具有starter安全依赖项的springframework.security包?_Java_Spring_Gradle_Spring Security_Dependency Management - Fatal编程技术网

Java 找不到具有starter安全依赖项的springframework.security包?

Java 找不到具有starter安全依赖项的springframework.security包?,java,spring,gradle,spring-security,dependency-management,Java,Spring,Gradle,Spring Security,Dependency Management,我正在为我的项目使用spring boot和spring starter依赖项。 我在Gradle中尝试了SpringStarter安全依赖项,但在项目中只找到了安全包。IDE是IntelliJ IDEA‎. 我的build.gradle文件: buildscript { ext { springBootVersion = '1.2.7.RELEASE' } repositories { mavenCentral() } d

我正在为我的项目使用spring boot和spring starter依赖项。 我在Gradle中尝试了SpringStarter安全依赖项,但在项目中只找到了安全包。IDE是IntelliJ IDEA‎.

我的build.gradle文件:

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') 
}
除了安全性之外的所有库都可以在外部库中找到

项目中类的一个示例:

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
 */

另外,我尝试了很多不同版本的spring security core,但什么都没有发生。

在多次处理这个问题后,我发现以下解决方案100%适用于我:

  • 转到文件|使缓存无效
  • 删除存储所有依赖项的文件夹(~/.gradle/适用于UNIX系统)-如果该文件夹在失效后存在
  • 重新启动Intellij IDEA
  • 通过刷新渐变重新导入渐变依赖项:

  • 这是你的实际进口声明吗?@M.Deinum是的,是的。。找不到安全子文件夹:/这确实是您的导入语句吗?目前它是非法的,甚至不会编译,因为它缺少
    *…您重新导入依赖项了吗?转到查看->工具窗口->渐变。单击最左边的按钮(刷新)。这可能需要一段时间。