0

春のアプリケーションのクラスパスにディレクトリがあります。ResouceLoader を使用して、そのディレクトリ内のすべてのファイルをロードするにはどうすればよいですか。

// bean for test context
public class DatabaseLoader {
    @Autowired
    protected ResourceLoader myLoader;

    private Logger log = LoggerFactory.getLogger(this.getClass());

    @PostConstruct
    public void init() throws IOException, FileNotFoundException {
        Resource[] resources = myLoader.getResource("classpath:fixtures/*.sql");
        //codepopulate in memory db with all test fixtures
        for (Resource r: resources) {
            //populate in memory db with data in this resource.
        }
    }
}
4

1 に答える 1