2017-02-07 26 views
0

我試圖使用flyway和gradle設置數據庫遷移。任務失敗,出現以下錯誤Gradle flywayMigrate發出內存異常

* Exception is: 
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':flywayMigrate'. 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84) 
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55) 
     at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:61) 
     at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) 
     at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88) 
     at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:45) 
     at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51) 
     at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) 
     at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 
     at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) 
     at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:233) 
     at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215) 
     at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:74) 
     at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:55) 
     at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) 
     at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) 
Caused by: java.lang.OutOfMemoryError: Java heap space 
     at org.flywaydb.core.internal.util.FileCopyUtils.copy(FileCopyUtils.java:117) 
     at org.flywaydb.core.internal.util.FileCopyUtils.copyToByteArray(FileCopyUtils.java:68) 
     at org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource.loadAsBytes(ClassPathResource.java:100) 
     at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.extractMigrationInfo(SqlMigrationResolver.java:140) 
     at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.resolveMigrations(SqlMigrationResolver.java:112) 
     at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.resolveMigrations(SqlMigrationResolver.java:41) 
     at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.collectMigrations(CompositeMigrationResolver.java:126) 
     at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.doFindAvailableMigrations(CompositeMigrationResolver.java:108) 
     at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.resolveMigrations(CompositeMigrationResolver.java:94) 
     at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.resolveMigrations(CompositeMigrationResolver.java:42) 
     at org.flywaydb.core.internal.info.MigrationInfoServiceImpl.refresh(MigrationInfoServiceImpl.java:96) 
     at org.flywaydb.core.internal.command.DbValidate$2.doInTransaction(DbValidate.java:136) 
     at org.flywaydb.core.internal.command.DbValidate$2.doInTransaction(DbValidate.java:131) 
     at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72) 
     at org.flywaydb.core.internal.command.DbValidate.validate(DbValidate.java:131) 
     at org.flywaydb.core.Flyway.doValidate(Flyway.java:1014) 
     at org.flywaydb.core.Flyway.access$300(Flyway.java:52) 
     at org.flywaydb.core.Flyway$1.execute(Flyway.java:925) 
     at org.flywaydb.core.Flyway$1.execute(Flyway.java:919) 
     at org.flywaydb.core.Flyway.execute(Flyway.java:1320) 
     at org.flywaydb.core.Flyway.migrate(Flyway.java:919) 
     at org.flywaydb.core.Flyway$migrate$0.call(Unknown Source) 
     at org.flywaydb.gradle.task.FlywayMigrateTask.run(FlywayMigrateTask.groovy:30) 
     at org.flywaydb.gradle.task.FlywayMigrateTask$run.callCurrent(Unknown Source) 
     at org.flywaydb.gradle.task.AbstractFlywayTask.runTask(AbstractFlywayTask.groovy:75) 

我嘗試以下

echo $GRADLE_OPTS 
-Xmx2048m 

echo $JAVA_OPTS 
-Xmx2048m 

增加了一些對gradle這個屬性也設置:

cat ~/.gradle/gradle.properties 
org.gradle.parallel=true 
org.gradle.daemon=true 
org.gradle.jvmargs=-Xms1024m -Xmx2048m 

沒有幫助,有什麼建議嗎?

回答

0
buildscript { 
    dependencies { 
     classpath 'mysql:mysql-connector-java:5.1.34' 
    } 
} 


plugins { 
    id "org.flywaydb.flyway" version "4.0.3" 
} 

flyway { 
    url = 'jdbc:mysql://localhost:3306/mydb' 
    user = 'root' 
    password = 'abc!23' 
    schemas = ['mydb'] 
    baselineVersion = 1 
    baselineDescription = "Baselining myDB Schema" 
} 

基本上我使用的是FlyWay的一個非常舊的版本,它導致了Java堆空間 - 我的壞。 上面的這個構建腳本可以是任何想要在MYSQL上使用FlyWay執行數據庫遷移的人的資源。