Saturday, 15 May 2010

Spring-boot with Liquibase Overloading Property -



Spring-boot with Liquibase Overloading Property -

i using spring boot , liquibase. using url guidelines

http://docs.spring.io/spring-boot/docs/current-snapshot/reference/htmlsingle/

in pom.xml, below entry nowadays spring boot knows liquibase.

<dependency> <groupid>org.liquibase</groupid> <artifactid>liquibase-core</artifactid> </dependency>

and set changelog file in resources folder. db.changelog-master.xml

now spring boot first tring find db.changelog-master.yaml in classpath , throwing exception this.

cannot find changelog location: class path resource [db/changelog/db.changelog-master.yaml

to prepare issue, have added bean below in class , tried set changelog proprty.

@configuration @componentscan @enableautoconfiguration public class sampledatajpaapplication { @autowired liquibaseproperties properties; @autowired private datasource datasource; @bean public springliquibase liquibase() { springliquibase liquibase = new springliquibase(); properties.setchangelog("classpath:/db/changelog/db.changelog-master.xml"); liquibase.setchangelog(this.properties.getchangelog()); liquibase.setcontexts(this.properties.getcontexts()); liquibase.setdatasource(this.datasource); liquibase.setdefaultschema(this.properties.getdefaultschema()); liquibase.setdropfirst(this.properties.isdropfirst()); liquibase.setshouldrun(this.properties.isenabled()); homecoming liquibase; } public static void main(string[] args) throws exception { logger logger = loggerfactory.getlogger("sampledatajpaapplication"); springapplication springapplication = new springapplication(); springapplication.run(sampledatajpaapplication.class, args); } }

but failing message.

org.springframework.beans.factory.beancreationexception: error creating bean name 'sampledatajpaapplication': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: org.springframework.boot.autoconfigure.liquibase.liquibaseproperties sample.data.jpa.sampledatajpaapplication.properties; nested exception org.springframework.beans.factory.nosuchbeandefinitionexception: no qualifying bean of type [org.springframework.boot.autoconfigure.liquibase.liquibaseproperties] found dependency: expected @ to the lowest degree 1 bean qualifies autowire candidate dependency. dependency annotations: {@org.springframework.beans.factory.annotation.autowired(required=true)}

caused by: org.springframework.beans.factory.beancreationexception: not autowire field: org.springframework.boot.autoconfigure.liquibase.liquibaseproperties sample.data.jpa.sampledatajpaapplication.properties; nested exception org.springframework.beans.factory.nosuchbeandefinitionexception: no qualifying bean of type [org.springframework.boot.autoconfigure.liquibase.liquibaseproperties] found dependency: expected @ to the lowest degree 1 bean qualifies autowire candidate dependency. dependency annotations: {@org.springframework.beans.factory.annotation.autowired(required=true)}

please provide inputs here, why getting exception or there whatever other available way override same class can alter changelog property of liquibase properties.

i'm not exclusively sure exact runtime path alter log is, why don't utilize "liquibase.*" properties in application.properties? should able leave out liquibase @bean , allow boot you.

if prefer add together own liquibase @bean take hint , create sure define liquibaseproperties bean (e.g. declaring @enableconfigurationproperties(liquibaseproperties.class)).

spring-boot liquibase

No comments:

Post a Comment