Commit 92f4e945 by huluobin

# update

parent a8836dd9
package com.bailuntec.job; package com.bailuntec.job;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -19,19 +21,46 @@ import javax.sql.DataSource; ...@@ -19,19 +21,46 @@ import javax.sql.DataSource;
@Configuration @Configuration
public class DataSourceConfig { public class DataSourceConfig {
@Bean @Bean
@ConfigurationProperties(prefix = "spring.dataflow-datasource") @ConfigurationProperties(prefix = "spring.dataflow-datasource")
public DataSourceProperties dataflowDataSourceProperties() {
return new DataSourceProperties();
}
@Bean
public DataSource dataflowDataSource() { public DataSource dataflowDataSource() {
return DataSourceBuilder.create().build(); DataSourceProperties dataSourceProperties = dataflowDataSourceProperties();
return DataSourceBuilder
.create(dataSourceProperties.getClassLoader())
.driverClassName(dataSourceProperties.getDriverClassName())
.url(dataSourceProperties.getUrl())
.username(dataSourceProperties.getUsername())
.password(dataSourceProperties.getPassword())
.type(HikariDataSource.class)
.build();
} }
@Primary @Primary
@Bean @Bean
@ConfigurationProperties(prefix = "spring.dataflow") @ConfigurationProperties(prefix = "spring.datasource")
public DataSourceProperties bizDataSourceProperties() {
return new DataSourceProperties();
}
@Primary
@Bean
public DataSource bizDataSource() { public DataSource bizDataSource() {
return DataSourceBuilder.create().build(); DataSourceProperties dataSourceProperties = bizDataSourceProperties();
return DataSourceBuilder
.create(dataSourceProperties.getClassLoader())
.driverClassName(dataSourceProperties.getDriverClassName())
.url(dataSourceProperties.getUrl())
.username(dataSourceProperties.getUsername())
.password(dataSourceProperties.getPassword())
.type(HikariDataSource.class)
.build();
} }
} }
...@@ -8,7 +8,7 @@ spring: ...@@ -8,7 +8,7 @@ spring:
username: root username: root
password: '#7kfnymAM$Y9-Ntf' password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
dataflow-dataSource: dataflow-datasource:
url: jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT}/mysql url: jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT}/mysql
username: root username: root
password: ${mysql-root-password} password: ${mysql-root-password}
......
...@@ -4,12 +4,12 @@ spring: ...@@ -4,12 +4,12 @@ spring:
name: base-sync-ebay name: base-sync-ebay
# 数据配置 # 数据配置
datasource: datasource:
jdbcUrl: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datecenter_test?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datecenter_test?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true
username: root username: root
password: '#7kfnymAM$Y9-Ntf' password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
dataflow-dataSource: dataflow-datasource:
jdbcUrl: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datecenter_test?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datecenter_test?serverTimezone=GMT%2B8&characterEncoding=utf-8&rewriteBatchedStatements=true
username: root username: root
password: '#7kfnymAM$Y9-Ntf' password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment