In the Spring Boot application I want to read a resources that happens to be RSAPublicKey
.
Within the @SpringBootTest
that should simulate the app running I get the following behaviour:
@Value("classpath:./keys/public.pem")
RSAPublicKey[] key;
@Value("classpath:./keys/*.pem")
String[] pubRess;
@Value("classpath:./keys/*.pem")
Resource[] ress;
@Value("classpath:./keys/*.pem")
List<Resource> ressList;
resolves to:
I’ll address last two declarations which I find inconsistent the most:
When loaded using Resources[]
, the array length is 2 which is correct as in ./keys/
path there are really two .pem files.
When loading the same SpEl into the List<>
I get one resource element that is even incorrect:
class path resource [keys/*.pem]
when I would load the resources into the RSAPublicKey[]
array, with @Value("classpath:./keys/*.pem")
it would fail saying:
Caused by: java.io.UncheckedIOException: java.io.FileNotFoundException: class path resource [keys/*.pem] cannot be opened because it does not exist
so it was unable to resolve that *
in this case. Without the wildcard I can load one into the array as shown in the picture.
I find this pretty counter-intuitive. Is this behaviour intender or is it a bug?
I’m using: Java API level 11 on Azul 11.0.23 and Spring Boot 2.7.18 (can’t upgrade now)