I am following the spring security tutorial from this link on that tutorial third part. I have to use redis to hand away session information to resource backend.
Here my applicaiton.yml file:
server:
port: 9000
security:
sessions: NEVER
spring:
session:
store-type: redis
redis:
host: localhost
port: 6379
logging:
level:
org.springframework:
security: DEBUG
session: TRACE
Also, I use HeaderHttpSessionStrategy bean as a session strategy
@Bean
HeaderHttpSessionStrategy sessionStrategy() {
return new HeaderHttpSessionStrategy();
}
My pom couldn't find the related class declaration and give me
package org.springframework.session.web.http does not exist
Above error Here my pom.xml file.
<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>
</plugins>
</build>
I am new in spring and spring-security world. Can any advice solve this problem?
Edit:
After I added the new dependency in pom
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session</artifactId>
<version>1.3.5.RELEASE</version>
</dependency>
I solve the above problem but this time hit me the new one it says:
No session repository could be auto-configured, check your configuration (session store type is 'redis'
My redis configuration on application.yml is above. And I am using redis on docker. My docker yml is:
redis:
image: redis
ports:
- "6379:6379"
I got this error recently. I was using Spring Boot 2.4.0. I had added the dependency for Spring Session, but forgot to add one for Jedis.
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
When I first deployed, with that it gave me the message:
No session repository could be auto-configured, check your configuration (session store type is 'redis')
After I added this dependency and rebuilt my JAR, everything worked.
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
Perhaps that will help someone else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With