Class SessionSchemaEnvironmentPostProcessor

java.lang.Object
com.onec.desktop.SessionSchemaEnvironmentPostProcessor
All Implemented Interfaces:
org.springframework.boot.env.EnvironmentPostProcessor, org.springframework.core.Ordered

public class SessionSchemaEnvironmentPostProcessor extends Object implements org.springframework.boot.env.EnvironmentPostProcessor, org.springframework.core.Ordered
Ensures the Spring Session JDBC schema exists on persistent databases.

This starter puts spring-session-jdbc on the classpath, so HTTP sessions are persisted in the application datasource in every mode (server and desktop). Spring Boot only auto-creates the SPRING_SESSION tables for in-memory embedded databases (the initialize-schema=embedded default). So on PostgreSQL and on a file-backed H2 the tables are never created and the first session write fails with Table "SPRING_SESSION" not found / relation "spring_session" does not exist — e.g. a 500 on login from a plain bootRun with the default jdbc:h2:file: url.

For those datasources we force initialize-schema=always pointed at an idempotent (IF NOT EXISTS) mirror of the upstream schema, so it is safe to run on every boot against the persistent database. Defaults go in at lowest precedence so an application can still override them. In-memory H2 needs nothing — Spring Boot initializes that itself.

  • Constructor Details

    • SessionSchemaEnvironmentPostProcessor

      public SessionSchemaEnvironmentPostProcessor()
  • Method Details

    • postProcessEnvironment

      public void postProcessEnvironment(org.springframework.core.env.ConfigurableEnvironment environment, org.springframework.boot.SpringApplication application)
      Specified by:
      postProcessEnvironment in interface org.springframework.boot.env.EnvironmentPostProcessor
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered