class.getResource () and ClassLoader.getResource How to fill in the parameters in ()

Class.getResource(String Name) : Find the resource under the same path as the current calling Class
For example, my current Class below the impl package, then the Class. The getResource () is located in path:/D:/learnSpringboot/basicJava/out/production/basicJava impl /
1. If the query resources are the same as the current classpath, they are all under the impl package
Class.getResource(” XXX. XXX “)
Class.getResource(” /impl/ xxx.xxx “)
ClassLoader.getResource(String Name) : Find the resource file in the root directory, i.e. “/” or the classpath directory
2. If the query resource is not at the same level as the current class
For example, my current class below the impl package, so this. GetResource () is located in path:/D:/learnSpringboot/basicJava/out/production/basicJava /,
I have to use the relative path notation
This getResource (” XXX/XXX. XXX “)
 
Reference blog: https://blog.csdn.net/qq_33591903/article/details/91444342
https://blog.csdn.net/zhangshk_/article/details/82704010


Read More: