2016-12-10 9 views
0

私はliquibaseスクリプトを実行してPosgresql DB +スキーマを作成しようとしています。gradle liquibaseのプロパティを使用

ここにliquibase .groovy configsとscriptsとbuild.gradleの一部があります。例えば

build.gradle

apply plugin: 'liquibase'  
buildscript { 
    repositories { 
     mavenLocal() 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'org.liquibase:liquibase-gradle-plugin:1.2.0' 
     classpath "org.postgresql:postgresql:${postgreJdbcDriverVersion}" 
    } 
} 

sourceSets { 
    main { 
     java { 
      srcDir 'src/main/liquibase' 
     } 
    } 
} 

liquibase { 
    activities { 
     main { 
      File propsFile = new File("src/main/resources/database.properties") 
      Properties properties = new Properties() 
      properties.load(new FileInputStream(propsFile)) 
      changeLogFile 'src/main/liquibase/com/freemmy/sample/spring/acl/sample/db/main-changelog.groovy' 
      url "${dbUrl}" 
      username "${dbUsername}" 
      password "${dbPassword}" 
     } 
    } 
    runList = 'main' 
} 

Iは、主changelog.groovy に次のチェンジセットがあります。

changeSet(id: '2016-12-10-a', author: 'Dzmitry Dziokin', runInTransaction: false, runAlways: true, runOnChange: true, failOnError: false, dbms: 'postgresql') { 
     comment('Create the database role/login') 
     // Ok if the role exists 
     preConditions(onFail: 'CONTINUE', onFailMessage: 'Role already exists, continue') { 
      sqlCheck(expectedResult: '0') 
        { "select count(*) from pg_roles where rolname= '${dbUsername}'" } 
     } 
     sql(stripComments: true, splitStatements: false, endDelimiter: ';') { 
      "CREATE ROLE ${dbUsername} LOGIN PASSWORD '${dbPassword}'" 
     } 
    } 

をそして私は、プロパティdbUsernamedbPasswordを持っています。

しかし、ときに私は実行し、例えば、gradlew status私は、以下を参照してください。

Execution failed for task ':spring-acl-sample-db:status'. 

liquibase.exception.LiquibaseException:LiquiBaseを実行予期しないエラー:いいえ、そのようなプロパティ:クラスのDBUSERNAME:org.liquibase。 groovy.delegate.PreconditionDelegate

私はGoogleに尋ねましたが、解決策や提案は見つかりませんでした。

誰かが何が起こっているのか知っていますか?

答えて

0

dbUsernameとdbPasswordがプロパティファイルで定義されているとします。

あなたのGradleスクリプトでDBUSERNAMEとDBPASSWORDを定義する必要があります:あなたはおそらく補間でproperties接頭辞を使用する必要があります

def dbUsername = properties.getProperty("dbUsername") 
def dbPassword = properties.getProperty("dbPassword") 
0

url "${properties.dbUrl}" 
username "${properties.dbUsername}" 
password "${properties.dbPassword}" 
関連する問題