我尝试使用flyway和gradle设置数据库迁移。任务失败,出现以下错误
* 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 :(得分:1)
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执行数据库迁移的人的资源。