liquibase sql文件不工作并引发语法错误

0ve6wy6x  于 2021-06-17  发布在  Mysql
关注(0)|答案(0)|浏览(272)

我正在使用mysql 8.0.x,并尝试使用liquibase版本3.6.2来应用更改日志。
当我试图通过命令行更新changelog时,它可以很好地使用yaml格式,但是sql格式不适用于changeset。
这里是整个设置。 command-to-run.bat 文件就是我要发射的命令。
我认为问题与此相同,但解决办法不太管用。他们的问题是文件的格式不应该是utf-8bom格式,虽然这个问题是固定的,但我试图改变格式,我仍然有问题。
我使用的是liquibase给出的示例中的同一个sql文件。我得到的错误如下

Unexpected error running Liquibase: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--liquibase formatted sql

--changeset bob:1
create table item (
  id int not nu' at line 1 [Failed SQL: --liquibase formatted sql

--changeset bob:1
create table item (
  id int not null primary key,
  name varchar(255) not null,
  description varchar(255)
)]
liquibase.exception.MigrationFailedException: Migration failed for change set changelog-master.xml::third::akshay:
     Reason: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--liquibase formatted sql

--changeset bob:1
create table item (
  id int not nu' at line 1 [Failed SQL: --liquibase formatted sql

--changeset bob:1
create table item (
  id int not null primary key,
  name varchar(255) not null,
  description varchar(255)
)]
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:637)
        at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:53)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:78)
        at liquibase.Liquibase.update(Liquibase.java:202)
        at liquibase.Liquibase.update(Liquibase.java:179)
        at liquibase.integration.commandline.Main.doMigration(Main.java:1205)
        at liquibase.integration.commandline.Main.run(Main.java:191)
        at liquibase.integration.commandline.Main.main(Main.java:129)
Caused by: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--liquibase formatted sql

--changeset bob:1
create table item (
  id int not nu' at line 1 [Failed SQL: --liquibase formatted sql

--changeset bob:1
create table item (
  id int not null primary key,
  name varchar(255) not null,
  description varchar(255)
)]
        at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:356)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:57)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:125)
        at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1229)
        at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1211)
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:600)
        ... 7 common frames omitted
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--liquibase formatted sql

--changeset bob:1
create table item (
  id int not nu' at line 1
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
        at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:782)
        at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:666)
        at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:352)
        ... 12 common frames omitted

For more information, please use the --logLevel flag

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题