oracle.jdbc.type=oracle oracle.jdbc.driver=oracle.jdbc.OracleDriver oracle.jdbc.url=jdbc:oracle:thin:@[ip]:[port]:[dbdomain] oracle.jdbc.username=[username] oracle.jdbc.password=[password] pi.isUsed=true pi.jdbc.type=PI pi.jdbc.driver=com.osisoft.jdbc.Driver pi.jdbc.url=jdbc:pioledb://localhost/Data Source=[PI Server Address]; Integrated Security=SSPI/
<!-- Hikari Datasource --> <bean id="dataSource_Oracle" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"> <property name="driverClassName" value="${oracle.jdbc.driver}" /><!-- 无需指定,除非系统无法自动识别 --> <property name="jdbcUrl" value="${oracle.jdbc.url}" /> <property name="username" value="${oracle.jdbc.username}" /> <property name="password" value="${oracle.jdbc.password}" /> <property name="maximumPoolSize" value="100" /> <property name="minimumIdle" value="10" /> <property name="connectionTestQuery" value="select 1 from dual" /> <property name="dataSourceProperties"> <props> <prop key="cachePrepStmts">true</prop> <prop key="prepStmtCacheSize">250</prop> <prop key="prepStmtCacheSqlLimit">2048</prop> <prop key="useServerPrepStmts">true</prop> </props> </property> </bean> <bean id="dataSource_PI" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"> <property name="driverClassName" value="${pi.jdbc.driver}" /> <property name="jdbcUrl" value="${pi.jdbc.url}" /> <property name="maximumPoolSize" value="100" /> <property name="minimumIdle" value="10" /> <property name="dataSourceProperties"> <props> <prop key="cachePrepStmts">true</prop> <prop key="prepStmtCacheSize">250</prop> <prop key="prepStmtCacheSqlLimit">2048</prop> <prop key="useServerPrepStmts">true</prop> </props> </property> </bean> <bean id="dataSource" class="com.bkc.bpmp.core.datasource.DynamicDataSource"> <property name="targetDataSources"> <map key-type="java.lang.String"> <entry key="dataSource_Oracle" value-ref="dataSource_Oracle" /> <entry key="dataSource_PI" value-ref="dataSource_PI" /> </map> </property> <property name="defaultTargetDataSource" ref="dataSource_Oracle" /> </bean>
关于多数据源的详细使用,查看其它帖子。这里只是为了表示 采用 HikariCP 时,Spring配置文件是如何写的。