diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index ba67ff8170..831b99e408 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -28,11 +28,11 @@ epmet-commons-mybatis 2.0.0 - + org.springframework.boot spring-boot-starter-web diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcDataSourceConfig.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcDataSourceConfig.java new file mode 100644 index 0000000000..597ff902a5 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcDataSourceConfig.java @@ -0,0 +1,64 @@ +package com.epmet.jdbc.config; + +import com.alibaba.druid.pool.DruidDataSource; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +import javax.sql.DataSource; + +/** + * jdbc连接外部数据源配置 + */ +@Configuration +public class JdbcDataSourceConfig { + + // ----------------对接兰图的数据源------------------- + @Value("${spring.datasource.yantai.lantu.driver-class-name}") + private String yantaiLantuDriverClassName; + @Value("${spring.datasource.yantai.lantu.url}") + private String yantaiLantuUrl; + @Value("${spring.datasource.yantai.lantu.username}") + private String yantaiLantuUsername; + @Value("${spring.datasource.yantai.lantu.password}") + private String yantaiLantuPassword; + + @Value("${spring.datasource.yantai.lantu.initial-size}") + private Integer yantaiLantuInitialSize; + @Value("${spring.datasource.yantai.lantu.max-active}") + private Integer yantaiLantuMacActive; + @Value("${spring.datasource.yantai.lantu.min-idle}") + private Integer yantaiLantuMinIdle; + @Value("${spring.datasource.yantai.lantu.max-wait}") + private Long yantaiLantuMaxWait; + @Value("${spring.datasource.yantai.lantu.pool-prepared-statements}") + private Boolean yantaiLantuPreparedStatements; + @Value("${spring.datasource.yantai.lantu.max-pool-prepared-statement-per-connection-size}") + private Integer yantaiLantuPspcs; + @Value("${spring.datasource.yantai.lantu.time-between-eviction-runs-millis}") + private Long yantaiLantuTberm; + @Value("${spring.datasource.yantai.lantu.min-evictable-idle-time-millis}") + private Long yantaiLantuMeitm; + + // ----------------对接兰图的数据源------------------- + + /** + * 烟台-连接兰图的数据源 + * @return + */ + DataSource createYantaiLantuDataSource() { + DruidDataSource druidDataSource = new DruidDataSource(); + druidDataSource.setDriverClassName(yantaiLantuDriverClassName); + druidDataSource.setUrl(yantaiLantuUrl); + druidDataSource.setUsername(yantaiLantuUsername); + druidDataSource.setPassword(yantaiLantuPassword); + druidDataSource.setInitialSize(yantaiLantuInitialSize); + druidDataSource.setMaxActive(yantaiLantuMacActive); + druidDataSource.setMinIdle(yantaiLantuMinIdle); + druidDataSource.setMaxWait(yantaiLantuMaxWait); + druidDataSource.setPoolPreparedStatements(yantaiLantuPreparedStatements); + druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(yantaiLantuPspcs); + druidDataSource.setTimeBetweenEvictionRunsMillis(yantaiLantuTberm); + druidDataSource.setMinEvictableIdleTimeMillis(yantaiLantuMeitm); + return druidDataSource; + } +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcTemplateConfig.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcTemplateConfig.java new file mode 100644 index 0000000000..4f8be141f3 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcTemplateConfig.java @@ -0,0 +1,30 @@ +package com.epmet.jdbc.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfigurationPackage; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.core.JdbcTemplate; + +import javax.sql.DataSource; + +/** + * jdbcTemplate配置类 + */ +@Configuration +public class JdbcTemplateConfig { + + @Autowired + private JdbcDataSourceConfig jdbcDataSourceConfig; + + /** + * 烟台-兰图-jdbcTempalte对象 + * @return + */ + @Bean + JdbcTemplate yantaiLantuJdbcTemplate() { + DataSource yantaiLantuDataSource = jdbcDataSourceConfig.createYantaiLantuDataSource(); + return new JdbcTemplate(yantaiLantuDataSource); + } +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml index 11018f0592..184c73ee7b 100644 --- a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml +++ b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml @@ -52,6 +52,22 @@ spring: wall: config: multi-statement-allow: true + # 对接兰图数据源 + yantai: + lantu: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/epmet_gov_voice?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai + username: root + password: root + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 60000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + # 数据迁移工具flyway flyway: enabled: @spring.flyway.enabled@