springframework.security 找不到具有启动器安全依赖项的程序包?
springframework.security package not found with starter-security dependency?
我正在使用 spring boot 和 spring 启动依赖项 用于我的项目。
我尝试在 Gradle 中使用 spring 启动器安全依赖项,但在项目中找不到唯一的安全包。 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')
}
除安全之外的所有库都可以在外部库...
中找到
项目中class的一个例子:
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。我尝试了很多不同的 spring-security-core 发行版本,但没有任何反应。
在多次处理这个问题后,我遇到了以下对我 100% 有效的解决方案:
- 转到文件 |使缓存无效
- 删除存储所有依赖项的文件夹(对于 UNIX 系统,~/.gradle/)- 如果存在失效后
- 重启 Intellij IDEA
- 通过刷新 gradle 重新导入 gradle 依赖项:
我正在使用 spring boot 和 spring 启动依赖项 用于我的项目。 我尝试在 Gradle 中使用 spring 启动器安全依赖项,但在项目中找不到唯一的安全包。 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')
}
除安全之外的所有库都可以在外部库...
中找到项目中class的一个例子:
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。我尝试了很多不同的 spring-security-core 发行版本,但没有任何反应。
在多次处理这个问题后,我遇到了以下对我 100% 有效的解决方案:
- 转到文件 |使缓存无效
- 删除存储所有依赖项的文件夹(对于 UNIX 系统,~/.gradle/)- 如果存在失效后
- 重启 Intellij IDEA
- 通过刷新 gradle 重新导入 gradle 依赖项: