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
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:
- Word column after the text evenly distributed in the left and right two columns, rather than fill in the left column and then fill in the right column, how to do?
- es Failed to introspect Class [org.elasticsearch.client.RestHighLevelClient] from ClassLoader
- After verifying parameters with validation, springboot reports an error: no constructor found in package name + class name
- PHP:Fatal error: Class ‘COM’ not found in … How to deal with the problem
- Four ways to get Django parameters in request
- Create an Apex class that returns contacts based on incoming parameters
- C#: How to Use Httpclient to upload files with other parameters
- An error occurs when pymysql uses% d to pass in parameters
- Mybatis passes in multiple parameters to mapper. And uses @param details to report an error
- The differences between the equals method in the string class and the equals method in the object class
- #error identifier-list parameters may only be used in a function definition
- The solution to the problem that the method of interacting with database in the servlet class is invalid after the servlet submits 404, 500 refresh and becomes 404, and after connecting to the data pool
- Elasticsearch in Spring uses Spel to dynamically create Index of Documet class
- How to Fix ”is not in the sudoers file“ in Linux
- Problem solving of failed to read candidate component class in Java
- Failed to determine a suitable driver class error in mybatis
- Error creating bean with name ‘redisTemplate‘ defined in class path resource [xx/RedisConfig.class]
- The @ Autowired annotation in springboot is invalid in ordinary classes. How to solve and use the null pointer exception java.lang.nullpointerexception
- How to deal with NullPointerException error in row.getlong in spark – sparksql
- How to solve “import cv2 failed ImportError: DLL load fail: Cannot find the specified module” in Anaconda environment