Task: In the same directory with the jar-file is the properties file that you want to read.
Here I was advised such a code
URI uri = clazz.getProtectionDomain().getCodeSource().getLocation().toURI(); String path = new File(uri).getParent(); Everything worked fine until I contacted the spring-boot.
In the case of a regular jar, uri is returned in the form file:/path/name-of-jar.jar and everything works. But when using spring-boot, the address is a different jar:file:/path/name-of-jar.jar!/BOOT-INF/classes!/ And the subsequent call
new File(uri) falls with an error
java.lang.IllegalArgumentException: URI is not hierarchical
Is it somehow being treated? Here it is advised to simply trim the string to the desired type. But somehow I don’t really like the method