org.h2.jdbc.JdbcSQLException: 列 “Salman” 未找到;
2022-09-02 19:44:08
我已尝试在我的春季应用程序中运行以下测试。
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes=App1Application.class)
@Sql(scripts="customerTest.sql")
@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
public class customerTest {
@Autowired
customerRepository customerDB;
@Test
public void countRecords(){
assertThat(customerDB.count(),is(2l));
}
}
在客户测试.sql文件我有:
insert into customer(id,name,lastname) values(1,"name","lastname");
这是我的客户班
@Entity
@Data
public class customer {
@Id
@GeneratedValue
int id;
String name;
String lastname;
}
我也使用jpa:
public interface customerRepository extends JpaRepository<customer,Long>{
}
问题是,当我运行测试时,我面临错误:
org.h2.jdbc.JdbcSQLException: Column "Salman" not found; SQL statement:
insert into customer(id,name,lastname) values(1,"name","lastname")
同时,“萨勒曼”是一个值,而不是一列?
请注意,我正在使用spring-mvc,所以没有数据库,只有我的模型()由代码制作。customer