【问题标题】:Using spring-data-jdbc and spring-session-redis使用 spring-data-jdbc 和 spring-session-redis
【发布时间】:2021-01-06 00:17:02
【问题描述】:

好像spring-data-jdbc和spring-session-redis不能一起工作,至少没有任何额外配置是不行的。

我错过了什么吗?

这是我的错误:

.RepositoryConfigurationExtensionSupport : Spring Data JDBC - Could not safely identify store assignment for repository candidate interface ca.code3.timekeeper.repository.ClientRepository. If you want this repository to be a JDBC repository, consider annotating your entities with one of these annotations: org.springframework.data.relational.core.mapping.Table.

只使用 spring data-jdbc 就像一个魅力。

【问题讨论】:

    标签: spring jdbc redis spring-data spring-session


    【解决方案1】:

    spring-session-data-redis 依赖引入了spring-data-redis 依赖。

    由于您还使用spring-data-jdbc,Spring Data 需要一种方法来区分它应该使用哪种持久化技术。

    由于应用程序有多个 Spring Data 模块,Spring Data 进入严格的存储库配置模式。

    您应该在日志中看到以下消息

    找到多个 Spring Data 模块,进入严格的存储库配置模式!

    这意味着 Spring Data 将在存储库或域类上查找详细信息来决定 Spring Data 模块绑定。

    在这种情况下,由于您想为您的域类使用 JDBC,您应该使用 @Table 对其进行注释。

    例如:

    interface PersonRepository extends CrudRepository<Person, Long> { … }
    
    @Table
    class Person { … }
    

    reference documentation 中有一个关于使用具有多个 Spring Data 模块的存储库的部分。

    【讨论】:

      猜你喜欢
      • 2021-09-13
      • 2016-05-31
      • 2016-07-08
      • 1970-01-01
      • 2019-02-12
      • 1970-01-01
      • 2022-06-21
      • 1970-01-01
      • 2018-12-16
      相关资源
      最近更新 更多