我的配置文件:
# H2
spring.h2.console.enabled=true
spring.h2.console.path=/h2
# Datasource
spring.datasource.url=jdbc:h2:file:~/test
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
我的data.sql脚本是这样的:
CREATE TABLE IF NOT EXISTS people (
ID INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
vname varchar(255) not null
);
INSERT INTO people(vname) VALUES ('Chuck Norris');
执行此操作时,INSERT失败并显示错误:找不到“VNAME”列。
您是否已经创建了没有VNAME列的表PEOPLE?如果表已存在,则SQL不会触及它。删除数据库文件,然后重试......