I have running a spring boot application as a jar file on a server (open shift). I need different keystores and truststores depending on the environment. This means I can't commit those files but need to load them over a config map to the server. I placed the files in a seperatly created folder /etc/trusts and the application is running in the /app folder. In my configuration I address the keysore and truststore with /etc/trusts/keystore.p12 and /etc/trusts/truststore.p12 but I get the error:
"class path resource [etc/trusts/keystore.p12] cannot be opened because it does not exist"
But it exists and can see it on the server. How can I get it running so that spring boot can access the files in the /etc/trusts folder?
Info: I checked if the config has the leading slash /etc and it is correctly stored, so only the error message doesn't use it.
How I try to load the files:
val resource: Resource = resourceLoader.getResource(fileLocation)
return resource.inputStream
For my local environment I have the files within src/main/resources and address them in the config with classpath:keystore.p12 etc. It works well.
Thank you in advance for any assistance.
As can been seen in documentation of getResource u need to specify whether the resource is on classpath
or in your case file
.
So you have to prepend file:
to your path e.g.:
val resource: Resource = resourceLoader.getResource(`file:/etc/trusts/keystore.p12`)