Obtain the absolute path of the classpath (src/main/resources)

Paste the code first

private static String basePath = Thread.currentThread().getContextClassLoader().getResource("").getPath();

Reason: The method is executed through the thread, so we can go back to the class loader through the thread, so as to get the path of the resource in this class loader.

Guess you like

Origin blog.csdn.net/hyx1249273846/article/details/113726700