0

出于测试目的,我正在尝试预填充由 Hibernate 创建的表。我有这个hibernate.cfg.xml

<!-- Prepopulate database with these DML scripts -->
<property name="hibernate.hbm2ddl.import_files">/genres.sql</property>

我已将文件添加到文件夹genres.sql的根目录,src但它不执行文件?

这是genres.sql文件:

INSERT INTO genre (naam) VALUES ("Action");
INSERT INTO genre (naam) VALUES ("Adventure");
INSERT INTO genre (naam) VALUES ("Animation");
INSERT INTO genre (naam) VALUES ("Biography");
INSERT INTO genre (naam) VALUES ("Comedy");

为什么这不起作用?

4

1 回答 1

0

该文件位于类路径中,因为它位于/src目录下,但 IntelliJ 仅查找特定扩展名,.sql而不是其中之一。

通过转到设置或使用CTRL+ALT+S您转到Compiler右侧的快捷方式Resource Patterns,在此处添加.sql扩展程序,它工作正常。

于 2012-10-30T00:13:57.073 回答