回答

0

下面應該工作:

<bean id="schema1EM" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
    ... 
    <property name="jpaVendorAdapter"> 
    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> 
     ... 
    </bean> 
    </property> 
    <property name="packagesToScan" value="org.example.domain.schema1"/> 
</bean> 

<bean id="schema2EM" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
    ... 
    <property name="jpaVendorAdapter"> 
    <bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"> 
     ... 
    </bean> 
    </property> 
    <property name="packagesToScan" value="org.example.domain.schema2"/> 
</bean> 

<jpa:repositories base-package="org.example.data.schema1" entity-manager-factory-ref="schema1EM"/> 
<jpa:repositories base-package="org.example.data.schema2" entity-manager-factory-ref="schema2EM"/> 

schema1EM將被分配到包org.example.data.schema1schema2EMorg.example.data.schema2下被分配給那些在聲明的所有存儲庫。你將不得不通過包來分離域類和存儲庫接口,以便Spring自動佈線可以工作。

相關問題