Multiple database with Spring+Hibernate+JPA

后端 未结 6 1535
别跟我提以往
别跟我提以往 2020-12-04 13:43

I\'m trying to configure Spring+Hibernate+JPA for work with two databases (MySQL and MSSQL).

My datasource-context.xml:



        
6条回答
  •  清歌不尽
    2020-12-04 14:10

    You need to use persistenceXmlLocations property (note the plural) rather than persistenceXmlLocation. It's a string array, so it'll be auto-converted from list:

    
      
        classpath*:config/persistence.local.xml
        classpath*:config/persistence.remote.xml
      
      ...
    

    Update (based on edit)

    Your entityManagerFactory does not specify persistenceUnitName property. You have to do so explicitly because you're defining more than one persistence unit and entityManagerFactory has to know which one to use.

提交回复
热议问题