【发布时间】:2020-08-28 01:05:39
【问题描述】:
是否可以使用 @Value 从 Maven 的 test/resources 目录加载文件/资源?
例如像这样:
@Value("${test/resources/path/to/file}") File file
编辑:
我试过这个:
@Value("${someFile}") FileSystemResource file;
但在运行时我看到它代表工作目录而不是 test/resources 中的文件
【问题讨论】:
-
没有
test/resources,因为它是类路径的一部分,所以删除test/resources部分。
标签: java spring spring-boot maven spring-boot-test