提示:这里简述项目相关背景:
Caused by: java.sql.SQLSyntaxErrorException: Table 'codetest.SPRING_SESSION' doesn't exist at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.25.jar:8.0.25] at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.25.jar:8.0.25] at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953) ~[mysql-connector-java-8.0.25.jar:8.0.25] at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1092) ~[mysql-connector-java-8.0.25.jar:8.0.25] at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1040) ~[mysql-connector-java-8.0.25.jar:8.0.25] at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1348) ~[mysql-connector-java-8.0.25.jar:8.0.25] at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:1025) ~[mysql-connector-java-8.0.25.jar:8.0.25] at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:3253) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.filter.FilterAdapter.preparedStatement_executeUpdate(FilterAdapter.java:1092) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeUpdate(FilterEventAdapter.java:491) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:3251) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.wall.WallFilter.preparedStatement_executeUpdate(WallFilter.java:695) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:3251) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.filter.FilterAdapter.preparedStatement_executeUpdate(FilterAdapter.java:1092) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeUpdate(FilterEventAdapter.java:491) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:3251) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.filter.FilterAdapter.preparedStatement_executeUpdate(FilterAdapter.java:1092) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeUpdate(FilterEventAdapter.java:491) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:3251) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.executeUpdate(PreparedStatementProxyImpl.java:194) ~[druid-1.2.5.jar:1.2.5] at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeUpdate(DruidPooledPreparedStatement.java:255) ~[druid-1.2.5.jar:1.2.5] at org.springframework.jdbc.core.JdbcTemplate.lambda$update$2(JdbcTemplate.java:965) ~[spring-jdbc-5.3.7.jar:5.3.7] at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:651) ~[spring-jdbc-5.3.7.jar:5.3.7] ... 16 more
pom.xml
文件中引入了<dependency> <groupId>org.springframework.session</groupId> <artifactId>spring-session-jdbc</artifactId> </dependency>
spring: session: # 在关系型数据库中设置spring会话 store-type: jdbc # 为了使其自动创建,需要指定该设置。设置后,Spring将使用Spring -session-jdbcjar中正确的SQL初始化脚本 jdbc: initialize-schema: always
spring.session.store-type =jdbc spring.session.jdbc.initialize-schema =always
spring-session-jdbc
删除该引用也可以解决报错MySQLSyntaxErrorException: Table ‘***.SPRING_SESSION’ doesn’t exist
spring-session用mysql实现session共享实践