我正在关注该教程第三部分的此链接中的 Spring Security 教程。我必须使用 redis 将会话信息交给资源后端。
这是我的 application.yml 文件:
server:
port: 9000
security:
sessions: NEVER
spring:
session:
store-type: redis
redis:
host: localhost
port: 6379
logging:
level:
org.springframework:
security: DEBUG
session: TRACE
Run Code Online (Sandbox Code Playgroud)
另外,我使用 HeaderHttpSessionStrategy bean 作为会话策略
@Bean
HeaderHttpSessionStrategy sessionStrategy() {
return new HeaderHttpSessionStrategy();
}
Run Code Online (Sandbox Code Playgroud)
我的pom找不到相关的类声明并给我
包 org.springframework.session.web.http 不存在
上面的错误这里是我的 pom.xml 文件。
<properties>
<java.version>14</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin> …Run Code Online (Sandbox Code Playgroud)