0
У меня есть каталог в моем пути к классам в моем весеннем приложении. Как загрузить все файлы в этом каталоге с помощью ResouceLoader.spring framework: загрузить все ресурсы из classpath
// 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.
}
}
}
взглянуть на http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/ core/io/support/PathMatchingResourcePatternResolver.html – fateddy
fateddy: любые образцы кода? – riship89
Найдите пример кода как ответ ниже. Если это решит вашу проблему, пожалуйста, примите ответ. – fateddy