简体   繁体   中英

Spring Data - Repository bean ID

I cannot understand how to explicitly assign an ID to a repository bean in Spring Data.

To be clear, suppose I defined the following interface in package com.acme.repositories

public interface MyJpaRepo extends JpaRespository<MyEntity, Long> {
}

As per documentation I can activate Spring Data JPA repositories simply by adding

<jpa:repositories base-package="com.acme.repositories" />

Last, suppose that I have another bean in the same context which constructor requires a JpaRepository to be passed in. I would define it like that

<bean class="x.y.z.MyBean">
    <constructor-arg name="repository" ref="XXX" />
</bean>

Now, what should I use in place of XXX ? Or, even better, how can I explicitly assign an ID to the MyJpaRepo repository beans?

Thanks!

In place of XXX use myJpaRepo .

source: Spring Data Jpa document reference for repository id

<bean class="x.y.z.MyBean">
    <constructor-arg name="repository" ref="<with qualified path>MyJpaRepo " />
</bean>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM