对于最新的稳定版本,请使用 Spring Framework 7.0.6!spring-doc.cadn.net.cn

@Sql

@Sql 用于注解测试类或测试方法,以配置在集成测试期间针对指定数据库运行的SQL脚本。以下示例展示了如何使用它:spring-doc.cadn.net.cn

@Test
@Sql({"/test-schema.sql", "/test-user-data.sql"}) (1)
void userTest() {
	// run code that relies on the test schema and test data
}
1 为此测试运行两个脚本。
@Test
@Sql("/test-schema.sql", "/test-user-data.sql") (1)
fun userTest() {
	// run code that relies on the test schema and test data
}
1 为此测试运行两个脚本。