我不知道如何在yml中使用配置文件创建多个数据源,并将生成的数据源用于xml上下文属性。 任何人都可以帮助我?
application.yml
spring:
profiles.active: development
---
spring:
profiles: development
datasource:
db-db2:
url: jdbc:db2://db2url:50000/database
username: username
password: pwd
driver-class-name: com.ibm.db2.jcc.DB2Driver
test-on-borrow: true
validation-query: VALUES current date
db-oracle:
url: jdbc:oracle:thin:@db_contract_dev
username: username
password: pwd
driver-class-name: oracle.jdbc.OracleDriver
test-on-borrow: true
validation-query: SELECT 1 FROM dual
application.xml中
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="db-db2"/>
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
<property name="persistenceUnitName" value="PU" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="JpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
</bean>
<jpa:repositories base-package="com.inc.dao.repository"
entity-manager-factory-ref="entityManagerFactory"
transaction-manager-ref="transactionManager"/>
我尝试将datasource用于entitymanager工厂
的 <property name="dataSource" ref="db-db2"/>