spring-boot nicht geladen liquibase change auf gradle build

Bin ich mit Spring-boot 1.1.1.RELEASE, und ich habe eine H2-Datenbank, die beim Start erstellt werden. Wenn ich meine main-Klasse aus IntelliJ, alles funktioniert gut. Wenn ich mit "gradle build-test" ich bekomme Fehler auf meinem integration-tests:

Caused by: java.lang.IllegalStateException: Cannot find changelog location: class path resource [db/changelog/db.changelog-master.yaml] (please add changelog or check your Liquibase configuration)
    at org.springframework.util.Assert.state(Assert.java:385)
    at org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.checkChangelogExists(LiquibaseAutoConfiguration.java:80)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)

Hier ist mein gradle-Datei:

apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'jacoco'
apply plugin: 'maven'

project.ext {
    springBootVersion = '1.1.1.RELEASE'
}

buildscript {
    repositories {
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        maven { url "http://repo.spring.io/libs-milestone" }
        maven { url "http://repo.spring.io/libs-snapshot" }
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.0.1.RELEASE")

    }
}

jar {
    baseName = 'my-app'
    version = '0.1.0'
}

repositories {
    mavenCentral()
    maven { url "http://repo.spring.io/libs-milestone" }
    maven { url "https://repository.jboss.org/nexus/content/repositories/releases" }
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
    maven { url "http://repo.spring.io/snapshot" }
    maven { url 'http://repo.spring.io/milestone' }
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
    compile("org.springframework.boot:spring-boot:1.0.1.RELEASE")
    compile("org.springframework.boot:spring-boot-starter-thymeleaf")
    compile("org.springframework.boot:spring-boot-starter-security")
    compile("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
    compile("org.springframework.security:spring-security-web:4.0.0.M1")
    compile("org.springframework.security:spring-security-config:4.0.0.M1")
    compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity3:2.1.1.RELEASE')

    compile("org.springframework:spring-orm:4.0.0.RC1")
    compile("org.hibernate:hibernate-core:4.3.4.Final")
    compile("org.hibernate:hibernate-entitymanager:4.3.4.Final")
    compile("org.hibernate:hibernate-validator")

    compile("com.h2database:h2:1.3.172")
    compile("joda-time:joda-time:2.3")
    compile("org.codehaus.groovy.modules.http-builder:http-builder:0.7.1")
    compile('org.codehaus.groovy:groovy-all:2.2.1')
    compile('org.jadira.usertype:usertype.jodatime:2.0.1')
    compile("org.liquibase:liquibase-core")

    testCompile('org.spockframework:spock-core:1.0-groovy-2.0-SNAPSHOT') {
        exclude group: 'org.codehaus.groovy', module: 'groovy-all'
    }

    testCompile('org.spockframework:spock-spring:1.0-groovy-2.0-SNAPSHOT') {
        exclude group: 'org.spockframework', module: 'spock-core'
        exclude group: 'org.spockframework', module: 'spring-beans'
        exclude group: 'org.spockframework', module: 'spring-test'
        exclude group: 'org.codehaus.groovy', module: 'groovy-all'
    }
    testCompile("org.springframework.boot:spring-boot-starter-test:$springBootVersion")
    testCompile('org.codehaus.groovy.modules.http-builder:http-builder:0.7+')
    testCompile("junit:junit")
}

jacocoTestReport {
    group = "Reporting"
    description = "Generate Jacoco coverage reports after running tests."
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.11'
}

Ich habe sowohl die src/main/resources und src/test/resources eine Anwendung.Eigenschaften-Datei enthält den folgenden Eintrag:

liquibase.changeLog=classpath:db/changelog/db.changelog-master.xml

Und dann in beiden src/main/resources/db/changelog und src/test/resources/db/changelog habe ich eine db.changelog-master.xml, Wenn ich das Projekt erstellen, sehe ich, dass bauen/resources/test und bauen/Ressourcen/main haben die Anwendung.Eigenschaften, db/changelog/db.changelog-master.xml es.

Dies würde zu sein scheinen ein classpath-Problem, da es funktioniert innerhalb von IntelliJ und nicht die Kommandozeile. Kann jemand empfehlen, was ich tun könnte falsch?

  • Ich Stimme, dass es klingt wie ein classpath-problem. Nachdem Sie ausgeführt haben "gradle build", was in build/resources/main und bauen/resources/test?
  • Ich habe beides, Meister und bauen: /build/resources/.../db/changelog/db.changelog-master.xml bauen/Ressourcen/.../Anwendung.Eigenschaften zusätzlich zu den erwarteten Dateien. Also, alles wird dort abgelegt.
  • Ich nehme an, Sie haben nicht individuelle Gradle test-Aufgabe überhaupt zu einer änderung Ihrer classpath? Vielleicht könnten Sie teilen sich ein Projekt irgendwo, die zeigt das problem?
  • Kann ich leider nicht teilen und das gesamte Projekt. Und meine bauen.gradle-Datei nicht alle das testen von bestimmten Aufgaben auf Sie. Ich habe update mein Beitrag mit meinem gradle-Datei.
InformationsquelleAutor sonoerin | 2014-07-03
Schreibe einen Kommentar