- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
几天以来,我一直在努力解决这个问题,但并未真正了解其背后的原因。
使用 Liquibase、PostgreSQL 和 H2DB(用于测试)。
Liquibase 在使用 PostgreSQL 时工作正常,但是一旦我需要运行在 H2DB 上执行的测试,它们就会因为 ${now} 属性的解析异常而失败,只要它没有被有效值替换(至少我是这么认为的)。
这是我创建表的变更集:
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<property name="now" value="now()" dbms="h2"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>
<!--
Added the entity Container.
-->
<changeSet id="20180424154826-1" author="developer">
<createTable tableName="container">
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="name" type="varchar(255)">
<constraints nullable="false" />
</column>
<column name="description" type="varchar(2000)">
<constraints nullable="true" />
</column>
<column name="container_type" type="varchar(255)">
<constraints nullable="true" />
</column>
<column name="created" type="timestamp">
<constraints nullable="true" />
</column>
</createTable>
<dropDefaultValue tableName="container" columnName="created" columnDataType="datetime"/>
</changeSet>
</databaseChangeLog>
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<property name="now" value="now()" dbms="h2"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>
<changeSet id="20180425154950-1" author="developer">
<loadData catalogName="container"
encoding="UTF-8"
file="config/liquibase/containers.csv"
schemaName="public"
separator=";"
quotchar="'"
tableName="container">
</loadData>
</changeSet>
</databaseChangeLog>
id;name;description;container_type;created
1;'Human';'Human container';HUMAN;${now}
2;'IT';'IT container';IT;${now}
3;'Physical';'Physical container';PHYSICAL;${now}
4;'Intangible';'Intangible container';INTANGIBLE;${now}
2018-04-26 11:30:20.350 ERROR 17993 --- [ main] liquibase : classpath:config/liquibase/master.xml: config/liquibase/changelog/20180425154950_added_Containers_data.xml::20180425154950-1::developer: Change Set config/liquibase/changelog/20180425154950_added_Containers_data.xml::20180425154950-1::developer failed. Error: Cannot parse "TIMESTAMP" constant "${now}"; SQL statement:
INSERT INTO public.container (id, name, description, container_type, created) VALUES ('1', 'Human', 'Human container', 'HUMAN', '${now}') -- ('1', 'Human', 'Human container', 'HUMAN', '${now}') [22007-197] [Failed SQL: INSERT INTO public.container (id, name, description, container_type, created) VALUES ('1', 'Human', 'Human container', 'HUMAN', '${now}')]
2018-04-26 11:30:20.352 WARN 17993 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [eu/hermeneut/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.MigrationFailedException: Migration failed for change set config/liquibase/changelog/20180425154950_added_Containers_data.xml::20180425154950-1::developer:
Reason: liquibase.exception.DatabaseException: Cannot parse "TIMESTAMP" constant "${now}"; SQL statement:
INSERT INTO public.container (id, name, description, container_type, created) VALUES ('1', 'Human', 'Human container', 'HUMAN', '${now}') -- ('1', 'Human', 'Human container', 'HUMAN', '${now}') [22007-197] [Failed SQL: INSERT INTO public.container (id, name, description, container_type, created) VALUES ('1', 'Human', 'Human container', 'HUMAN', '${now}')]
2018-04-26 11:30:20.400 ERROR 17993 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [eu/hermeneut/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.MigrationFailedException: Migration failed for change set config/liquibase/changelog/20180425154950_added_Containers_data.xml::20180425154950-1::developer:
Reason: liquibase.exception.DatabaseException: Cannot parse "TIMESTAMP" constant "${now}"; SQL statement:
INSERT INTO public.container (id, name, description, container_type, created) VALUES ('1', 'Human', 'Human container', 'HUMAN', '${now}') -- ('1', 'Human', 'Human container', 'HUMAN', '${now}') [22007-197] [Failed SQL: INSERT INTO public.container (id, name, description, container_type, created) VALUES ('1', 'Human', 'Human container', 'HUMAN', '${now}')]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1630)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:297)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set config/liquibase/changelog/20180425154950_added_Containers_data.xml::20180425154950-1::developer:
Reason: liquibase.exception.DatabaseException: Cannot parse "TIMESTAMP" constant "${now}"; SQL statement:
INSERT INTO public.container (id, name, description, container_type, created) VALUES ('1', 'Human', 'Human container', 'HUMAN', '${now}') -- ('1', 'Human', 'Human container', 'HUMAN', '${now}') [22007-197] [Failed SQL: INSERT INTO public.container (id, name, description, container_type, created) VALUES ('1', 'Human', 'Human container', 'HUMAN', '${now}')]
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:619)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:79)
at liquibase.Liquibase.update(Liquibase.java:214)
at liquibase.Liquibase.update(Liquibase.java:192)
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:431)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:388)
at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:94)
at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.afterPropertiesSet(AsyncSpringLiquibase.java:84)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1688)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1626)
... 43 common frames omitted
Caused by: liquibase.exception.DatabaseException: Cannot parse "TIMESTAMP" constant "${now}"; SQL statement:
INSERT INTO public.container (id, name, description, container_type, created) VALUES ('1', 'Human', 'Human container', 'HUMAN', '${now}') -- ('1', 'Human', 'Human container', 'HUMAN', '${now}') [22007-197] [Failed SQL: INSERT INTO public.container (id, name, description, container_type, created) VALUES ('1', 'Human', 'Human container', 'HUMAN', '${now}')]
at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:309)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:113)
at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1277)
at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1259)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:582)
... 53 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLException: Cannot parse "TIMESTAMP" constant "${now}"; SQL statement:
INSERT INTO public.container (id, name, description, container_type, created) VALUES ('1', 'Human', 'Human container', 'HUMAN', '${now}') -- ('1', 'Human', 'Human container', 'HUMAN', '${now}') [22007-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.value.ValueTimestamp.parse(ValueTimestamp.java:147)
at org.h2.value.Value.convertTo(Value.java:1071)
at org.h2.table.Column.convert(Column.java:177)
at org.h2.command.dml.Insert.insertRows(Insert.java:166)
at org.h2.command.dml.Insert.update(Insert.java:134)
at org.h2.command.CommandContainer.update(CommandContainer.java:102)
at org.h2.command.Command.executeUpdate(Command.java:261)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:233)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:205)
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95)
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:307)
... 58 common frames omitted
Caused by: java.lang.IllegalArgumentException: ${now}
at org.h2.util.DateTimeUtils.parseDateValue(DateTimeUtils.java:345)
at org.h2.util.DateTimeUtils.parseTimestamp(DateTimeUtils.java:460)
at org.h2.value.ValueTimestamp.parse(ValueTimestamp.java:145)
... 69 common frames omitted
最佳答案
即使对于 h2 数据库,获取当前时间戳的内置函数也是 CURRENT_TIMESTAMP
引用这里-> http://www.h2database.com/html/functions.html#current_timestamp
所以改变这个
<property name="now" value="now()" dbms="h2"/>
<property name="now" value="current_timestamp()" dbms="h2"/>
关于timestamp - org.h2.jdbc.JdbcSQLException : Cannot parse "TIMESTAMP" constant "${now}";,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50039621/
标题基本上说明了一切。 我主要对更新案例感兴趣。假设我们正在尝试更新具有时间戳记字段的记录,并且我们希望将该字段设置为记录更新的时间戳记。有没有办法做到这一点? 最佳答案 经过一些实验,我找到了合适的
我正在学习一门类(class),其中我必须将日期转换为 unix 时间戳。 import pandas as pd df = pd.read_csv('file.csv') print type(df
我在两个不同的数据库中运行了相同的语句:我的本地数据库和 Oracle Live SQL . CREATE TABLE test( timestamp TIMESTAMP DEFAULT SY
我在两个不同的数据库中运行了相同的语句:我的本地数据库和 Oracle Live SQL . CREATE TABLE test( timestamp TIMESTAMP DEFAULT SY
bson.timestamp.Timestamp需要两个参数:time 和 inc。 time 显然是存储在 Timestamp 中的时间值。 什么是公司?它被描述为递增计数器,但它有什么用途呢?它应
2016-08-18 04:52:14 是我从数据库中获取的时间戳,用于跟踪我想从哪里加载更多记录,这些记录小于该时间 这是代码 foreach($explode as $stat){
我想将 erlang:timestamp() 的结果转换为正常的日期类型,公历类型。 普通日期类型表示“日-月-年,时:分:秒”。 ExampleTime = erlang:timeStamp(),
我想将 erlang:timestamp() 的结果转换为正常的日期类型,公历类型。 普通日期类型表示“日-月-年,时:分:秒”。 ExampleTime = erlang:timeStamp(),
我是 Java 新手。我正在使用两个 Timestamp 对象 dateFrom和dateTo 。我想检查是否dateFrom比 dateTo早 45 天。我用这个代码片段来比较这个 if(dateF
在将 panda 对象转换为时间戳时,我遇到了这个奇怪的问题。 Train['date'] 值类似于 01/05/2014,我正在尝试将其转换为 linuxtimestamp。 我的代码: Train
我正在努力让我的代码运行。时间戳似乎有问题。您对我如何更改代码有什么建议吗?我看到之前有人问过这个问题,但没能成功。 这是我在运行代码时遇到的错误:'Timestamp' object has no
我正在尝试运行以下查询: SELECT startDate FROM tests WHERE startDate BETWEEN TIMESTAMP '1555248497'
我正在使用 Athena 查询以 bigInt 格式存储的日期。我想将其转换为友好的时间戳。 我试过了: from_unixtime(timestamp DIV 1000) AS readab
最近进行了一些数据库更改,并且 hibernate 映射出现了一些困惑。 hibernate 映射: ...other fields 成员模型对象: public class Mem
rng = pd.date_range('2016-02-07', periods=7, freq='D') print(rng[0].day) print(rng[0].month) 7 2 我想要
rng = pd.date_range('2016-02-07', periods=7, freq='D') print(rng[0].day) print(rng[0].month) 7 2 我想要
我必须在我的数据库中保存 ServerValue.TIMESTAMP 但它必须是一个字符串。当我键入 String.valueOf(ServerValue.TIMESTAMP); 或 ServerVa
在我的程序中,每个表都有一列 last_modified: last_modified int8 DEFAULT (date_part('epoch'::text, now()::timestamp)
我想将此时间戳对象转换为日期时间此对象是在数据帧上使用 asfreq 后获得的这是最后一个索引 Timestamp('2018-12-01 00:00:00', freq='MS') 想要的输出 2
我有一个包含时间序列传感器数据的大表。大型是指分布在被监控的各个 channel 中的从几千到 10M 的记录。对于某种传感器类型,我需要计算当前读数和上一个读数之间的时间间隔,即找到当前读数之前的最
我是一名优秀的程序员,十分优秀!