spring-security-oauth2-autoconfigure的类路径问题:找不到EnableResourceServer

时间:2018-10-03 19:51:11

标签: maven spring-security

我创建了一个project in Github来演示此问题。为什么在类路径中没有org.springframework.security.oauth2.config.annotation.web.configuration?

我有一个使用Spring Security 4.x的现有Spring Boot 1.5.x项目,我正在尝试使用spring-security-oauth2-autoconfigure升级到带有Spring Security 5.x的Spring Boot 2.x:

<dependency>
  <groupId>org.springframework.security.oauth.boot</groupId>
  <artifactId>spring-security-oauth2-autoconfigure</artifactId>
  <version>2.0.5.RELEASE</version>
</dependency>

这是失败的导入之一:

import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
  

Application.java:[9,79]包org.springframework.security.oauth2.config.annotation.web.configuration不存在     [错误] /Users/stevemitchell/Downloads/problem-spring-security-oauth2-boot/src/main/java/com/demo/service/auth/Application.java:[16,2]找不到符号       符号:class EnableResourceServer

我可以在“ mvn依赖项:树”中看到org.springframework.security.oauth:spring-security-oauth2:jar:2.3.3.RELEASE:runtime。

$ mvn dependency:tree
...
[INFO] \- org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:jar:2.0.5.RELEASE:compile
[INFO]    +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO]    +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.6:compile
[INFO]    |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.6:compile
[INFO]    +- org.springframework.boot:spring-boot:jar:2.0.5.RELEASE:compile
[INFO]    +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.5.RELEASE:compile
[INFO]    +- org.springframework.security.oauth:spring-security-oauth2:jar:2.3.3.RELEASE:runtime
[INFO]    |  +- org.springframework:spring-webmvc:jar:5.0.9.RELEASE:compile
[INFO]    |  +- commons-codec:commons-codec:jar:1.11:runtime
[INFO]    |  \- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:runtime
[INFO]    |     \- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:runtime
[INFO]    +- org.springframework.security:spring-security-jwt:jar:1.0.9.RELEASE:compile
[INFO]    |  \- org.bouncycastle:bcpkix-jdk15on:jar:1.56:compile
[INFO]    |     \- org.bouncycastle:bcprov-jdk15on:jar:1.56:compile
[INFO]    \- org.springframework:spring-web:jar:5.0.9.RELEASE:compile

这应该编译。我想念什么?

1 个答案:

答案 0 :(得分:1)