in my target folder, there are 2 folders, lib and conf. all the properties files are placed in conf folder, and jars are placed in lib foulder.
previous to spring
Actually, the most easiest way is to put application.properties
and your.jar
into the same directory, and just java -jar your.jar
will automatically load this external config file.
And if you are trying to load some context/files from resource folder via ClassPathResource
, when you read the file don't use pathResource.getFile()
, instead use pathResource.getInputStream()
, getFile()
works well within your IDE, however it doesn't work with the standalone jar
.