當前位置: 首頁>>代碼示例>>Java>>正文


Java SpringLiquibase類代碼示例

本文整理匯總了Java中liquibase.integration.spring.SpringLiquibase的典型用法代碼示例。如果您正苦於以下問題:Java SpringLiquibase類的具體用法?Java SpringLiquibase怎麽用?Java SpringLiquibase使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SpringLiquibase類屬於liquibase.integration.spring包,在下文中一共展示了SpringLiquibase類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: migrate

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
/**
 * Migrate database with liquibase.
 * @param tenantKey the tenant key
 */
@SneakyThrows
public void migrate(String tenantKey) {
    final StopWatch stopWatch = createStarted();
    try {
        log.info("START - SETUP:CreateTenant:liquibase tenantKey: {}", tenantKey);
        SpringLiquibase liquibase = new SpringLiquibase();
        liquibase.setResourceLoader(resourceLoader);
        liquibase.setDataSource(dataSource);
        liquibase.setChangeLog(CHANGE_LOG_PATH);
        liquibase.setContexts(liquibaseProperties.getContexts());
        liquibase.setDefaultSchema(tenantKey);
        liquibase.setDropFirst(liquibaseProperties.isDropFirst());
        liquibase.setChangeLogParameters(DatabaseUtil.defaultParams(tenantKey));
        liquibase.setShouldRun(true);
        liquibase.afterPropertiesSet();
        log.info("STOP  - SETUP:CreateTenant:liquibase tenantKey: {}, result: OK, time = {} ms", tenantKey,
            stopWatch.getTime());
    } catch (Exception e) {
        log.info("STOP  - SETUP:CreateTenant:liquibase tenantKey: {}, result: FAIL, error: {}, time = {} ms",
            tenantKey, e.getMessage(), stopWatch.getTime());
        throw e;
    }
}
 
開發者ID:xm-online,項目名稱:xm-uaa,代碼行數:28,代碼來源:TenantDatabaseService.java

示例2: runOnAllSchemasXm

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
private void runOnAllSchemasXm() throws LiquibaseException {

        for (String schema : getSchemas()) {
            if (schema.equals("default")) {
                schema = null;
            }

            log.info("Initializing Liquibase for schema {}", schema);
            try {
                SpringLiquibase liquibase = getXmSpringLiquibase(getDataSource());
                liquibase.setDefaultSchema(schema);
                liquibase.afterPropertiesSet();
                log.info("Liquibase run for schema {}", schema);
            } catch (Exception e) {
                log.error("Failed to initialize Liquibase for schema {}", schema, e);
            }
        }

    }
 
開發者ID:xm-online,項目名稱:xm-commons,代碼行數:20,代碼來源:XmMultiTenantSpringLiquibase.java

示例3: create

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
/**
 * Create database schema for tenant.
 *
 * @param tenant - the tenant
 */
public void create(Tenant tenant) {
    StopWatch stopWatch = createStarted();
    log.info("START - SETUP:CreateTenant:schema tenantKey={}", tenant.getTenantKey());
    DatabaseUtil.createSchema(dataSource, tenant.getTenantKey());
    log.info("STOP - SETUP:CreateTenant:schema tenantKey={}, time={}ms", tenant.getTenantKey(),
        stopWatch.getTime());
    try {
        stopWatch.reset();
        stopWatch.start();
        log.info("START - SETUP:CreateTenant:liquibase tenantKey={}", tenant.getTenantKey());
        SpringLiquibase liquibase = new SpringLiquibase();
        liquibase.setResourceLoader(resourceLoader);
        liquibase.setDataSource(dataSource);
        liquibase.setChangeLog(CHANGE_LOG_PATH);
        liquibase.setContexts(liquibaseProperties.getContexts());
        liquibase.setDefaultSchema(tenant.getTenantKey());
        liquibase.setDropFirst(liquibaseProperties.isDropFirst());
        liquibase.setShouldRun(true);
        liquibase.afterPropertiesSet();
        log.info("STOP - SETUP:CreateTenant:liquibase tenantKey={}, time={}ms", tenant.getTenantKey(),
            stopWatch.getTime());
    } catch (LiquibaseException e) {
        throw new RuntimeException("Can not migrate database for creation tenant " + tenant.getTenantKey(), e);
    }
}
 
開發者ID:xm-online,項目名稱:xm-ms-entity,代碼行數:31,代碼來源:TenantDatabaseService.java

示例4: liquibase

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
@Bean
public SpringLiquibase liquibase() {
    myLogger.info("Initializing Liquibase.");
    syncIfNecessary();

    // If the database is out of date, this will update it to the latest
    // schema.
    SpringLiquibase lb = new SpringLiquibase();
    lb.setChangeLog("classpath:db/changelog/db.changelog-master.yaml");
    lb.setDataSource(myDataSource);
    Map<String, String> params = Maps.newHashMap();
    params.put("verbose", "true");
    lb.setChangeLogParameters(params);
    lb.setShouldRun(true);

    return lb;
}
 
開發者ID:swri-robotics,項目名稱:bag-database,代碼行數:18,代碼來源:LiquibaseConfig.java

示例5: getXmSpringLiquibase

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
private SpringLiquibase getXmSpringLiquibase(DataSource dataSource) {
    SpringLiquibase liquibase = new SpringLiquibase();
    liquibase.setChangeLog(getChangeLog());
    liquibase.setChangeLogParameters(getParameters());
    liquibase.setContexts(getContexts());
    liquibase.setLabels(getLabels());
    liquibase.setDropFirst(isDropFirst());
    liquibase.setShouldRun(isShouldRun());
    liquibase.setRollbackFile(getRollbackFile());
    liquibase.setResourceLoader(getResourceLoader());
    liquibase.setDataSource(dataSource);
    liquibase.setDefaultSchema(getDefaultSchema());
    return liquibase;
}
 
開發者ID:xm-online,項目名稱:xm-commons,代碼行數:15,代碼來源:XmMultiTenantSpringLiquibase.java

示例6: create

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
/**
 * Create database schema for tenant.
 *
 * @param tenant - the tenant
 */
public void create(Tenant tenant) {
    final StopWatch stopWatch = createStarted();
    final String tenantKey = tenant.getTenantKey();

    log.info("START - SETUP:CreateTenant:schema tenantKey: {}", tenantKey);
    DatabaseUtil.createSchema(dataSource, tenantKey);
    log.info("STOP  - SETUP:CreateTenant:schema tenantKey: {}, time = {} ms", tenantKey,
        stopWatch.getTime());
    try {
        stopWatch.reset();
        stopWatch.start();
        log.info("START - SETUP:CreateTenant:liquibase tenantKey: {}", tenantKey);
        SpringLiquibase liquibase = new SpringLiquibase();
        liquibase.setResourceLoader(resourceLoader);
        liquibase.setDataSource(dataSource);
        liquibase.setChangeLog(CHANGE_LOG_PATH);
        liquibase.setContexts(liquibaseProperties.getContexts());
        liquibase.setDefaultSchema(tenantKey);
        liquibase.setDropFirst(liquibaseProperties.isDropFirst());
        liquibase.setShouldRun(true);
        liquibase.afterPropertiesSet();
        log.info("STOP  - SETUP:CreateTenant:liquibase tenantKey: {}, result: OK, time = {} ms", tenantKey,
            stopWatch.getTime());
    } catch (LiquibaseException e) {
        log.info("STOP  - SETUP:CreateTenant:liquibase tenantKey: {}, result: FAIL, error: {}, time = {} ms",
            tenantKey, e.getMessage(), stopWatch.getTime());
        throw new RuntimeException("Can not migrate database for creation tenant " + tenantKey, e);
    }
}
 
開發者ID:xm-online,項目名稱:xm-ms-dashboard,代碼行數:35,代碼來源:TenantDatabaseService.java

示例7: getSpringLiquibase

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
private SpringLiquibase getSpringLiquibase() {
    final SpringLiquibase liquibase = new SpringLiquibase();
    liquibase.setChangeLog(LIQUIBASE_CHANGELOG_LOCATION);
    liquibase.setResourceLoader(resourceLoader);
    liquibase.setDataSource(dataSource);
    return liquibase;
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:8,代碼來源:LiquibaseConfig.java

示例8: testNoDataSource

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
@Test
public void testNoDataSource() throws Exception {
	this.context.register(LiquibaseAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	assertThat(this.context.getBeanNamesForType(SpringLiquibase.class).length)
			.isEqualTo(0);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:9,代碼來源:LiquibaseAutoConfigurationTests.java

示例9: testDefaultSpringLiquibase

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
@Test
public void testDefaultSpringLiquibase() throws Exception {
	this.context.register(EmbeddedDataSourceConfiguration.class,
			LiquibaseAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
	assertThat(liquibase.getChangeLog())
			.isEqualTo("classpath:/db/changelog/db.changelog-master.yaml");
	assertThat(liquibase.getContexts()).isNull();
	assertThat(liquibase.getDefaultSchema()).isNull();
	assertThat(liquibase.isDropFirst()).isFalse();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:14,代碼來源:LiquibaseAutoConfigurationTests.java

示例10: testXmlChangeLog

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
@Test
public void testXmlChangeLog() throws Exception {
	EnvironmentTestUtils.addEnvironment(this.context,
			"liquibase.change-log:classpath:/db/changelog/db.changelog-override.xml");
	this.context.register(EmbeddedDataSourceConfiguration.class,
			LiquibaseAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
	assertThat(liquibase.getChangeLog())
			.isEqualTo("classpath:/db/changelog/db.changelog-override.xml");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:13,代碼來源:LiquibaseAutoConfigurationTests.java

示例11: testJsonChangeLog

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
@Test
public void testJsonChangeLog() throws Exception {
	EnvironmentTestUtils.addEnvironment(this.context,
			"liquibase.change-log:classpath:/db/changelog/db.changelog-override.json");
	this.context.register(EmbeddedDataSourceConfiguration.class,
			LiquibaseAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
	assertThat(liquibase.getChangeLog())
			.isEqualTo("classpath:/db/changelog/db.changelog-override.json");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:13,代碼來源:LiquibaseAutoConfigurationTests.java

示例12: testSqlChangeLog

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
@Test
public void testSqlChangeLog() throws Exception {
	EnvironmentTestUtils.addEnvironment(this.context,
			"liquibase.change-log:classpath:/db/changelog/db.changelog-override.sql");
	this.context.register(EmbeddedDataSourceConfiguration.class,
			LiquibaseAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
	assertThat(liquibase.getChangeLog())
			.isEqualTo("classpath:/db/changelog/db.changelog-override.sql");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:13,代碼來源:LiquibaseAutoConfigurationTests.java

示例13: testOverrideContexts

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
@Test
public void testOverrideContexts() throws Exception {
	EnvironmentTestUtils.addEnvironment(this.context,
			"liquibase.contexts:test, production");
	this.context.register(EmbeddedDataSourceConfiguration.class,
			LiquibaseAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
	assertThat(liquibase.getContexts()).isEqualTo("test, production");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:12,代碼來源:LiquibaseAutoConfigurationTests.java

示例14: testOverrideDefaultSchema

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
@Test
public void testOverrideDefaultSchema() throws Exception {
	EnvironmentTestUtils.addEnvironment(this.context,
			"liquibase.default-schema:public");
	this.context.register(EmbeddedDataSourceConfiguration.class,
			LiquibaseAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
	assertThat(liquibase.getDefaultSchema()).isEqualTo("public");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:12,代碼來源:LiquibaseAutoConfigurationTests.java

示例15: testOverrideDropFirst

import liquibase.integration.spring.SpringLiquibase; //導入依賴的package包/類
@Test
public void testOverrideDropFirst() throws Exception {
	EnvironmentTestUtils.addEnvironment(this.context, "liquibase.drop-first:true");
	this.context.register(EmbeddedDataSourceConfiguration.class,
			LiquibaseAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
	assertThat(liquibase.isDropFirst()).isTrue();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:11,代碼來源:LiquibaseAutoConfigurationTests.java


注:本文中的liquibase.integration.spring.SpringLiquibase類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。