当前位置: 首页 > 知识库问答 >
问题:

在测试模式下使用飞行路线玩游戏:未找到“公共”架构

衡高寒
2023-03-14

我在开发和生产模式下(成功)使用飞行方式游戏插件。我还想在测试模式下使用它。文档说,它在测试模式下自动运行迁移。

我使用scala测试,我的测试用例被包装在一个假的应用程序中

val fakeApplication = FakeApplication(additionalConfiguration = Map(
  "db.default.driver"->"org.h2.Driver",
  "db.default.url"->"jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_DELAY=-1;",
  "db.default.user"->"",
  "db.default.password"->""
))

运行测试用例时,自动转换失败,并显示“未找到Schema public”:

[info]   com.googlecode.flyway.core.command.FlywaySqlScriptException: Error executing     statement at line 17: CREATE TABLE "public"."schema_version" (
[info]     "version_rank" INT NOT NULL,
[info]     "installed_rank" INT NOT NULL,
[info]     "version" VARCHAR(50) NOT NULL,
[info]     "description" VARCHAR(200) NOT NULL,
[info]     "type" VARCHAR(20) NOT NULL,
[info]     "script" VARCHAR(1000) NOT NULL,
[info]     "checksum" INT,
[info]     "installed_by" VARCHAR(100) NOT NULL,
[info]     "installed_on" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
[info]     "execution_time" INT NOT NULL,
[info]     "success" BOOLEAN NOT NULL
[info] )
[info]   at com.googlecode.flyway.core.dbsupport.SqlScript.execute(SqlScript.java:92)
[info]   at     com.googlecode.flyway.core.metadatatable.MetaDataTableImpl.createIfNotExists(MetaDataTableIm    pl.java:114)
[info]   at     com.googlecode.flyway.core.metadatatable.MetaDataTableImpl.lock(MetaDataTableImpl.java:120)
[info]   at     com.googlecode.flyway.core.command.DbMigrate$1.doInTransaction(DbMigrate.java:137)
[info]   at     com.googlecode.flyway.core.command.DbMigrate$1.doInTransaction(DbMigrate.java:135)
[info]   at     com.googlecode.flyway.core.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72    )
[info]   at com.googlecode.flyway.core.command.DbMigrate.migrate(DbMigrate.java:135)
[info]   at com.googlecode.flyway.core.Flyway$1.execute(Flyway.java:872)
[info]   at com.googlecode.flyway.core.Flyway$1.execute(Flyway.java:819)
[info]   at com.googlecode.flyway.core.Flyway.execute(Flyway.java:1200)
[info]   ...
[info]   Cause: org.h2.jdbc.JdbcSQLException: Schema "public" nicht gefunden
[info] Schema "public" not found; SQL statement:
[info] CREATE TABLE "public"."schema_version" (
[info]     "version_rank" INT NOT NULL,
[info]     "installed_rank" INT NOT NULL,
[info]     "version" VARCHAR(50) NOT NULL,
[info]     "description" VARCHAR(200) NOT NULL,
[info]     "type" VARCHAR(20) NOT NULL,
[info]     "script" VARCHAR(1000) NOT NULL,
[info]     "checksum" INT,
[info]     "installed_by" VARCHAR(100) NOT NULL,
[info]     "installed_on" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
[info]     "execution_time" INT NOT NULL,
[info]     "success" BOOLEAN NOT NULL
[info] ) [90079-172]
[info]   at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
[info]   at org.h2.message.DbException.get(DbException.java:169)
[info]   at org.h2.message.DbException.get(DbException.java:146)
[info]   at org.h2.command.Parser.getSchema(Parser.java:613)
[info]   at org.h2.command.Parser.getSchema(Parser.java:620)
[info]   at org.h2.command.Parser.parseCreateTable(Parser.java:5254)
[info]   at org.h2.command.Parser.parseCreate(Parser.java:3841)
[info]   at org.h2.command.Parser.parsePrepared(Parser.java:324)
[info]   at org.h2.command.Parser.parse(Parser.java:279)
[info]   at org.h2.command.Parser.parse(Parser.java:251)

这个错误到底是什么意思?为什么它使用公共模式?我的数据库配置定义了“db.default”,而不是“db.public”。什么是公共模式?我没有在任何地方定义它。

关于如何使测试用例运行(或至少更进一步)的任何想法?

编辑:

我发现提示(与飞天/Spring和H2嵌入式数据库的模式相关问题)不要在h2数据库网址中使用MODE = MySQL。不幸的是,我似乎需要它来光滑。如果我不使用它,我会得到

[info]   com.googlecode.flyway.core.command.FlywaySqlScriptException: Error executing statement at line 10: SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"
[info]   at com.googlecode.flyway.core.dbsupport.SqlScript.execute(SqlScript.java:92)
[info]   at com.googlecode.flyway.core.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:72)
[info]   at com.googlecode.flyway.core.command.DbMigrate$2.doInTransaction(DbMigrate.java:243)
[info]   at com.googlecode.flyway.core.command.DbMigrate$2.doInTransaction(DbMigrate.java:241)
[info]   at com.googlecode.flyway.core.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72)
[info]   at com.googlecode.flyway.core.command.DbMigrate.applyMigration(DbMigrate.java:241)
[info]   at com.googlecode.flyway.core.command.DbMigrate.access$700(DbMigrate.java:44)
[info]   at com.googlecode.flyway.core.command.DbMigrate$1.doInTransaction(DbMigrate.java:186)
[info]   at com.googlecode.flyway.core.command.DbMigrate$1.doInTransaction(DbMigrate.java:135)
[info]   at com.googlecode.flyway.core.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72)
[info]   ...
[info]   Cause: org.h2.jdbc.JdbcSQLException: Syntax Fehler in SQL Befehl "SET SQL_MODE[*] = ""NO_AUTO_VALUE_ON_ZERO"""; erwartet "@, AUTOCOMMIT, MVCC, EXCLUSIVE, IGNORECASE, PASSWORD, SALT, MODE, COMPRESS_LOB, DATABASE, COLLATION, BINARY_COLLATION, CLUSTER, DATABASE_EVENT_LISTENER, ALLOW_LITERALS, DEFAULT_TABLE_TYPE, CREATE, HSQLDB.DEFAULT_TABLE_TYPE, PAGE_STORE, CACHE_TYPE, FILE_LOCK, DB_CLOSE_ON_EXIT, AUTO_SERVER, AUTO_SERVER_PORT, AUTO_RECONNECT, ASSERT, ACCESS_MODE_DATA, OPEN_NEW, JMX, PAGE_SIZE, RECOVER, NAMES, SCHEMA, DATESTYLE, SEARCH_PATH, SCHEMA_SEARCH_PATH, LOGSIZE"
[info] Syntax error in SQL statement "SET SQL_MODE[*] = ""NO_AUTO_VALUE_ON_ZERO"""; expected "@, AUTOCOMMIT, MVCC, EXCLUSIVE, IGNORECASE, PASSWORD, SALT, MODE, COMPRESS_LOB, DATABASE, COLLATION, BINARY_COLLATION, CLUSTER, DATABASE_EVENT_LISTENER, ALLOW_LITERALS, DEFAULT_TABLE_TYPE, CREATE, HSQLDB.DEFAULT_TABLE_TYPE, PAGE_STORE, CACHE_TYPE, FILE_LOCK, DB_CLOSE_ON_EXIT, AUTO_SERVER, AUTO_SERVER_PORT, AUTO_RECONNECT, ASSERT, ACCESS_MODE_DATA, OPEN_NEW, JMX, PAGE_SIZE, RECOVER, NAMES, SCHEMA, DATESTYLE, SEARCH_PATH, SCHEMA_SEARCH_PATH, LOGSIZE"; SQL statement:
[info] SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO" [42001-172]
[info]   at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
[info]   at org.h2.message.DbException.get(DbException.java:169)
[info]   at org.h2.message.DbException.getSyntaxError(DbException.java:194)
[info]   at org.h2.command.Parser.getSyntaxError(Parser.java:491)
[info]   at org.h2.command.Parser.parseSet(Parser.java:4676)
[info]   at org.h2.command.Parser.parsePrepared(Parser.java:407)
[info]   at org.h2.command.Parser.parse(Parser.java:279)
[info]   at org.h2.command.Parser.parse(Parser.java:255)
[info]   at org.h2.command.Parser.prepareCommand(Parser.java:218)
[info]   at org.h2.engine.Session.prepareLocal(Session.java:425)

所以slick好像在没有MODE=MySQL的情况下使用了H2不支持的SQL命令(或者我这里说错了?)

使用

"jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS \"public\"\\;"

导致相同的错误,就好像MODE=MySQL不存在一样(所以这正是上框中显示的错误)

共有2个答案

洪富
2023-03-14

这条线在应用中。属性与或与mysql模式一起使用

spring.datasource.url=jdbc:h2:mem:test;MODE=MYSQL;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS \"public\"\\;
姜晨
2023-03-14

将飞道模式设置为公共(全部大写),您应该没问题。(我希望:-)

 类似资料:
  • 游玩已下载的游戏 可游玩自(PlayStation®Store)下载(购买)的游戏。 开始游玩游戏 1. 选择 (游戏)的 (Memory Stick™) 或 (主机内存)。 2. 选择想启动之游戏的图示。 离开游戏 游玩游戏时按下PS按钮(HOME(归返)按钮)。请遵循画面指示,正确操作。 暂停游戏 保存游玩中的游戏进度,再暂时离开游戏。 游玩游戏时按下PS按钮。请遵循画面指示,正确操作。 要使

  • 自我介绍 为什么选择做游戏测试。 写过测试用例吗?(写过) 针对游戏里面排行榜的功能,设计一下测试用例,包括玩家的头像、昵称、杀敌数、加入联盟这些。 有一个武将,他的技能可以增加带兵数,针对这个设计测试用例。 游戏测试和软件测试的区别。 面试官是个很漂亮温柔的姐姐,想测试用例的时候有点紧张卡顿,她说没关系你可以想一下,讲软件测试和游戏测试的区别的时候也给了提示和扩充,氛围很好不紧张。但是因为没有过

  • 我使用Spock框架来运行我的测试。每个测试类上都有Spring的注释。正如我所看到的,每个测试类都需要上下文,在不同的类中运行几十个测试需要很多时间。是否有一种方法可以配置Spock测试类以在公共spring上下文下运行?

  • 我们一直使用flyway进行模式迁移,版本4 . x/5 . x——该表被命名为schema_version。现在,我们希望迁移到最新版本7.x。我已经看到一些信息,说明新表名已更改为flyway_schema_history,但我刚刚看到,表名看起来命名为flyway _ history _ schema(https://flywaydb . org/documentation/concepts

  • 可能入行真不太简单吧😭😭😭感觉是凉的

  • 游玩UMD™游戏     开始游玩游戏 1. 插入UMD™。 2. 选择 (游戏) > (UMD™)。 离开游戏 于游玩时按下PS按钮(HOME(归返)按钮)。请遵循画面指示,正确操作。 关于保存数据 保存数据会保存至Memory Stick™,并于(管理保存数据)显示。