标签:port 注解 ali des frame 重启 framework set 架构
背景
核心思想
使用
package com.test.integration.rpc.initdata; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.Resource; import org.springframework.jdbc.datasource.init.DataSourceInitializer; import org.springframework.jdbc.datasource.init.DatabasePopulator; import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; import javax.sql.DataSource; /** * @author test * @Description: 自定义初始化数据源 * @date 2020/4/11 */ @Configuration public class CustomizeDataSourceInitializer { @Value("classpath:testSql/test_farms.sql") private Resource functionScriptFarms; @Value("classpath:testSql/test_miners.sql") private Resource functionScriptMiners; @Value("classpath:testSql/test_pool_config.sql") private Resource functionScriptPoolConfig; @Bean public DataSourceInitializer dataSourceInitializer(final DataSource dataSource) { final DataSourceInitializer initializer = new DataSourceInitializer(); // 设置数据源 initializer.setDataSource(dataSource); initializer.setDatabasePopulator(databasePopulator()); return initializer; } private DatabasePopulator databasePopulator() { final ResourceDatabasePopulator populator = new ResourceDatabasePopulator(); populator.addScripts(functionScriptFarms); populator.addScripts(functionScriptMiners); populator.addScripts(functionScriptPoolConfig); return populator; } }
delete from `pool_configs`; INSERT INTO `pool_configs`(`pool_config_id`, `cdate`, `mdate`, `pool_config_mid` ) VALUES (1, ‘2020-04-10 18:02:54‘, ‘2020-04-10 18:02:54‘, ‘bcf2a18a-b38b-4e3a-8852-7efbabc7954d‘); INSERT INTO `pool_configs`(`pool_config_id`, `cdate`, `mdate`, `pool_config_mid` ) VALUES (2, ‘2020-04-10 18:02:54‘, ‘2020-04-10 18:02:54‘, ‘bcf3a18a-b38b-4e3a-8852-7efbabc7954d‘); INSERT INTO `pool_configs`(`pool_config_id`, `cdate`, `mdate`, `pool_config_mid` ) VALUES (3, ‘2020-04-10 18:02:54‘, ‘2020-04-10 18:02:54‘, ‘bcf4a18a-b38b-4e3a-8852-7efbabc7954d‘); INSERT INTO `pool_configs`(`pool_config_id`, `cdate`, `mdate`, `pool_config_mid` ) VALUES (4, ‘2020-04-10 18:02:54‘, ‘2020-04-10 18:02:54‘, ‘bcf5a18a-b38b-4e3a-8852-7efbabc7954d‘);
标签:port 注解 ali des frame 重启 framework set 架构
原文地址:https://www.cnblogs.com/zuiyue_jing/p/12681815.html