Reputation: 94
I am working on a project using Spring Boot 1.5.2.RELEASE and have been tasked with adding database backed HTTP sessions.
So, I got this working in the 2.0.0.RELEASE easily enough and the application started and created the tables spring_session and spring_session_attributes
Here's the properties I added to the later version that got things working:
spring.session.store-type=jdbc
spring.session.jdbc.initialize-schema=ALWAYS
Looking at spring-boot 1.5.2.RELEASE it seems to use spring-session 1.3.0.RELEASE as the managed version so I found the docs here: https://docs.spring.io/spring-session/docs/1.3.0.RELEASE/reference/html5/guides/httpsession-jdbc.html
No matter what I try I get the following error:
Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Tue Mar 20 14:02:06 GMT 2018 There was an unexpected error (type=Internal Server Error, status=500). PreparedStatementCallback; bad SQL grammar [SELECT S.SESSION_ID, S.CREATION_TIME, S.LAST_ACCESS_TIME, S.MAX_INACTIVE_INTERVAL, SA.ATTRIBUTE_NAME, SA.ATTRIBUTE_BYTES FROM SPRING_SESSION S LEFT OUTER JOIN SPRING_SESSION_ATTRIBUTES SA ON S.SESSION_ID = SA.SESSION_ID WHERE S.SESSION_ID = ?]; nested exception is org.postgresql.util.PSQLException: ERROR: relation "spring_session" does not exist Position: 127
Here is my application.properties (I am trying to get the tables to appear in my PostgreSQL database)- these tables should be created for me automatically, right?
spring.datasource.url=jdbc:postgresql://localhost:5432/sandbox
spring.datasource.password=sandbox
spring.datasource.username=sandbox
spring.thymeleaf.cache=false
spring.template.cache=false
spring.session.store-type=jdbc
spring.session.jdbc.initializer.enabled=true
Upvotes: 2
Views: 3605
Reputation: 94
Unfortunately I couldn’t get the tables to create automatically so I dug through the spring-session jar file for the schema and created them manually. Good news is that sessions are now persisted in my database!
Upvotes: 0
Reputation: 199
Can you try after adding this spring.session.jdbc.table-name=SPRING_SESSION
Upvotes: 0