Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
Multiple liquibase configurations in spring boot

I have spring boot application which use 2 databases. I defined 2 configurations providing specified datasources. I want to have that datasources managed separately by liquibase. I defined 2 separated changelog files.

The problem is that I can't define 2 separate beans for liquibase.

Here are my config classes:

...
public class CCSConfiguration {
    ...

    @Bean
    @ConfigurationProperties("ccs.liquibase")
    public LiquibaseProperties ccsLiquibaseProperties() {
        return new LiquibaseProperties();
    }

    @Bean
    public SpringLiquibase ccsLiquibase(LiquibaseProperties liquibaseProperties) {
        ...
    }
    ...
}



...
public class CCAConfiguration {
    ...
    @ConfigurationProperties("cca.liquibase")
    public LiquibaseProperties ccaLiquibaseProperties() {
        return new LiquibaseProperties();
    }

    @Bean
    public SpringLiquibase ccaLiquibase(LiquibaseProperties liquibaseProperties) {
        ...
    }
    ...
}

And properties:

cca:
    liquibase:
        change-log: classpath:config/liquibase/cca/master.xml
ccs:
    liquibase:
        change-log: classpath:config/liquibase/ccs/master.xml

With this config i get following error while running appliction:

2017-04-11 14:26:55.664  WARN 34292 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'liquibase' available
2017-04-11 14:26:55.711  WARN 34292 --- [  restartedMain] o.s.boot.SpringApplication               : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.config.internalCacheAdvisor' defined in class path resource [org/springframework/cache/annotation/ProxyCachingConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cache.interceptor.BeanFactoryCacheOperationSourceAdvisor]: Factory method 'cacheAdvisor' threw exception; nested exception is java.lang.NullPointerException)
2017-04-11 14:26:55.939 ERROR 34292 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean named 'liquibase' that could not be found.


Action:

Consider defining a bean named 'liquibase' in your configuration.

So, is it possible to define multiple liquibase beans for different datasources?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

there are two options:

  1. you define a bean named liquibase to let spring-boot integrated process to update your schema on you first DS. You have to handle the second one by hand

  2. you disable liquibase automatic update at startup with

enabled: false

and define your way DS and liquibase beans to update your two databases

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda