0

Currently, I am testing Spring Session using Spring Boot

When I add Spring Security to a dependency, Session is normally created and stored in the spring_session table, but if I remove the Spring Security dependency, Session is not created and is not saved in the spring_session table.

My current settings are as below.

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.session:spring-session-jdbc'
    compileOnly 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    compileOnly 'org.postgresql:postgresql'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.springframework.security:spring-security-test'
}
spring:
  profiles:
    active: local
---
server:
  servlet:
    session:
      timeout: 3600
spring:
  config:
    activate:
      on-profile: local
  datasource:
    driver-class-name: org.postgresql.Driver
    url: jdbc:postgresql://localhost/dummy
    username: post
    password: post
  jpa:
    hibernate:
      ddl-auto: create-drop
  session:
    store-type: jdbc
    jdbc:
      initialize-schema: always
hun
  • 31
  • 3
  • Does it show any error? did you try to add value to session and debug the code. – Mohd Alomar Jan 26 '21 at 08:46
  • No. The session is not saved because the wrappedSession is null in the commitSession method of the SessionRepositoryFilter, which does not generate an error. – hun Jan 27 '21 at 23:56
  • 1
    Does this answer your question? [Persist Spring Session without Spring Security](https://stackoverflow.com/questions/37355049/persist-spring-session-without-spring-security) – Eleftheria Stein-Kousathana Jan 29 '21 at 09:07
  • This is what I was looking for. Thank you! – hun Jan 31 '21 at 23:09

0 Answers0