在春天,我可以使用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 中做到这一点?我找到了一个解决方案 Micronaut 中是否有 Springs Resource 的等效项?添加 @Inject private DefaultClassPathResourceLoader resourceLoader;... Stream<URL> currencyStream = resourceLoader.getResources("currency/*.json"); long count = currencyStream.count();...但总是计数 0 =(
添加回答
举报
0/150
提交
取消