且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

spring-data:不是托管类型:类java.lang.Object

更新时间:2022-05-02 22:28:39

必须知道存储库管理的类型在bootstrap时,这意味着你需要实际创建一个这样的具体存储库:

The type the repository manages has to be known at bootstrap time, which means that you need to actually create a concrete repository like this:

interface NetworkRepository extends BaseRepository<Network, Long> { … }

您展示的代码中还有一些其他故障:

There are a few other glitches in the code you showed:


  • 网络类没有任何使用 @Id注释的属性

  • BaseRepository 应携带 @NoRepositoryBean 注释到表明它根本不应该被实例化。请参阅参考文档了解详情。

  • The Network class doesn't have any property annotated with @Id
  • BaseRepository should carry an @NoRepositoryBean annotation to indicate it's not supposed to be instantiated at all. See the reference documentation for details.