08-02-2023, 07:23 AM
I encountered the `@NoRepositoryBean` interface several times whilst reading the Spring Data documentation.
To quote from the documentation:
> If you're using automatic repository interface detection using the
> Spring namespace using the interface just as is will cause Spring
> trying to create an instance of MyRepository. This is of course not
> desired as it just acts as indermediate between Repository and the
> actual repository interfaces you want to define for each entity. To
> exclude an interface extending Repository from being instantiated as
> repository instance annotate it with `@NoRepositoryBean`.
However, I am still not sure when and where to use it. Can someone please advise and give me a concrete usage example?
To quote from the documentation:
> If you're using automatic repository interface detection using the
> Spring namespace using the interface just as is will cause Spring
> trying to create an instance of MyRepository. This is of course not
> desired as it just acts as indermediate between Repository and the
> actual repository interfaces you want to define for each entity. To
> exclude an interface extending Repository from being instantiated as
> repository instance annotate it with `@NoRepositoryBean`.
However, I am still not sure when and where to use it. Can someone please advise and give me a concrete usage example?