以下是使用 Bitronix 事务管理器的 Spring Boot应用程序的 Derby EmbeddedXADataSource
配置
package org.chorke.init.entity.config;
import javax.sql.DataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import bitronix.tm.resource.jdbc.PoolingDataSource;
@Configuration
@EnableTransactionManagement
public class BitronixConfiguration {
@Bean(initMethod = "init", destroyMethod = "close")
public DataSource dataSource() {
PoolingDataSource dataSource = new PoolingDataSource();
dataSource.setMaxPoolSize(10);
dataSource.setUniqueName("java:jboss/datasources/CKDerby_initDS");
dataSource.setClassName("org.apache.derby.jdbc.EmbeddedXADataSource");
dataSource.setAllowLocalTransactions(true);
dataSource.getDriverProperties().setProperty("user", "chorke_init");
dataSource.getDriverProperties().setProperty("password", "pa55w0rd");
dataSource.getDriverProperties().setProperty("createDatabase", "create");
dataSource.getDriverProperties().setProperty("databaseName", "/tmp/chorke_osuser/var/derby/init/chorke_init;shutdown=false");
return dataSource;
}
}
Spring Boot应用程序的Liquibase 配置
################################################################################
# application.properties
################################################################################
liquibase.change-log=classpath:/META-INF/migrations/db.changelog-master.xml
spring.main.show-banner: false
spring.profiles.active: test
启动 Spring Boot应用程序后, Liquibase 成功执行了更新操作,其中 Liquibase 或 Derby 本身正在关闭下面是Derby连接:
INFO 11/15/17 10:55 PM: liquibase: Successfully released change log lock
INFO 11/15/17 10:55 PM: liquibase: Shutting down derby connection: jdbc:derby:/tmp/chorke_osuser/var/derby/init/chorke_init;shutdown=true
由于Derby连接关闭导致应用程序失败。你对这个问题有什么解决方案吗?
答案 0 :(得分:0)
尝试添加:
<property name="shutdownEmbeddedDerby" value="false" dbms="derby"/>
对于变更集,这似乎可以防止在使用 Spring 上下文时关闭。
见: