如何配置 spring-session with spring-boot WITHOUT Redis 并且没有自动配置以使用另一个数据库存储

How to configure spring-session with spring-boot WITHOUT Redis and without auto configuration to use another db store

我想在没有 Redis 的情况下使用 spring-boot + spring-session,但使用 dynamodb 作为 sessionRepository 实现。

所有可用的示例都与 Redis 或 Hazelcast 紧密耦合,并且大部分是自动配置,抽象出正在初始化的 bean。此外,我的 spring 启动配置明确定义了一个

@Bean
    public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory(Environment env) {

        TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();

return factory;
}

我还为 spring-session 禁用了 spring-boot 自动配置 SessionAutoConfiguration.class

所以我有几个问题。

1. 我如何配置我的 spring-boot 项目,它有一个显式定义的 TomcatEmbeddedServletContainerFactory bean 以利用 use spring-session?

2. 我注意到 spring-session 与 Redis 和 Hazelcast(仅此而已)紧密结合。是否有人反对使用像 amazon dynamodb 这样的商店来实现会话存储库?

我在看https://github.com/spring-projects/spring-session/blob/master/spring-session/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java

让我了解如何配置我想要实现的目标,但我将 运行 保留在初始化异常中。如果有人能指出正确的方向,我将不胜感激。

使用 spring-session 版本:1.1.0.M1

I have also disabled the spring-boot autoconfiguration SessionAutoConfiguration.class for spring-session.

如果类路径中没有 Redis,则不需要禁用自动配置。

How do I configure my spring-boot project that has an explicitly defined TomcatEmbeddedServletContainerFactory bean to utilize use spring-session?

1.1.0.M1 参考讨论了如何使用 @EnableSpringHttpSession 执行此操作。例如:

@EnableSpringHttpSession
@Configuration
public class SpringHttpSessionConfig {
        @Bean
        public CusttomSessionRepository sessionRepository() {
                return new CusttomSessionRepository();
        }
}

I noticed spring-session is tightly coupled with Redis and Hazelcast (and nothing else). Are there any objections to using a store like amazon dynamodb for the session repository impl?

我们希望为不同的数据存储做出贡献(事实上,我们正在获得对 GemFire 的支持)。问题实际上更多的是实施它们的时间。

to give me an idea of how to configure what I want to achieve but I keep running into initialization exceptions.

听起来您正在尝试我提供的一些建议。但是,除非您提供有关您遇到的异常的详细信息,否则我无法提供帮助。