|
@@ -0,0 +1,49 @@
|
|
|
+package cn.com.qmth.examcloud.core.questions.starter.oracle;
|
|
|
+
|
|
|
+import javax.sql.DataSource;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
|
|
+import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.context.annotation.Primary;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author weiwenhai
|
|
|
+ * @date 2018.7.30
|
|
|
+ * @company qmth
|
|
|
+ * @describle 数据库连接池
|
|
|
+ */
|
|
|
+@Configuration("nativeOracleConfig")
|
|
|
+public class NativeOracleConfig {
|
|
|
+
|
|
|
+ @Bean(name = "primaryDataSource")
|
|
|
+ @Qualifier("primaryDataSource")
|
|
|
+ @Primary
|
|
|
+ @ConfigurationProperties(prefix="spring.datasource.primary")
|
|
|
+ public DataSource primaryDataSource() {
|
|
|
+ return DataSourceBuilder.create().build();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean(name = "secondaryDataSource")
|
|
|
+ @Qualifier("secondaryDataSource")
|
|
|
+ @ConfigurationProperties(prefix="spring.datasource.secondary")
|
|
|
+ public DataSource secondaryDataSource() {
|
|
|
+ return DataSourceBuilder.create().build();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean(name = "primaryJdbcTemplate")
|
|
|
+ public JdbcTemplate primaryJdbcTemplate(
|
|
|
+ @Qualifier("primaryDataSource") DataSource dataSource) {
|
|
|
+ return new JdbcTemplate(dataSource);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean(name = "secondaryJdbcTemplate")
|
|
|
+ public JdbcTemplate secondaryJdbcTemplate(
|
|
|
+ @Qualifier("secondaryDataSource") DataSource dataSource) {
|
|
|
+ return new JdbcTemplate(dataSource);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|