Question

I wan't separate my custom repository implementation from domain package. And, probablym some common interfaces. For example I want have structure like

  com
       domain
            Foo
            FooRepository
       common
            Bar
       persistence
            BarImpl

interface FooRepository extends Bar{}

<jpa:repositories base-package="com.domain" /> // smt else?

How I should config this?

Was it helpful?

Solution

The automatic pickup of the repository class only works if you place it in the very same package and use either the default postfix or define the suffix to use manually. So in your scenario you'd have to place a FooRepositoryImpl into the domain package. You can customize the suffix using the repository-impl-postfix attribute. If you'd like to place the implementation into another package you can declare the custom implementation bean manually using fooRepositoryImpl as bean id. The class can then reside in any package you want.

I assume that Bar is the interface containing the custom method declarations. Actually we recommend putting both the custom repository interface and implementation into the very same package and make it package protected to avoid it being available to clients individually. This way, all the clients actually see is the unified repository interface containing query methods and manually implemented ones.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top