【发布时间】:2019-08-15 14:03:30
【问题描述】:
在春天我可以使用 ResourceLoader 和 ResourcePatternUtils:
class Foobar {
private ResourceLoader resourceLoader;
@Autowired
public Foobar(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
Resource[] loadResources(String pattern) throws IOException {
return ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources(pattern);
}
}
并使用它
Resource[] resources = foobar.loadResources("classpath*:../../dir/*.txt");
我如何在 Micronaut 中做到这一点?
我找到了一个解决方案 Is there an equivalent for Springs Resource in Micronaut?
添加
@Inject
private DefaultClassPathResourceLoader resourceLoader;
...
Stream<URL> currencyStream = resourceLoader.getResources("currency/*.json");
long count = currencyStream.count();
...
但计数始终为 0 =(
【问题讨论】: