Get the project file path in springboot

Now I want to get the path of invoice.pdf file How to
Insert picture description here
get:

import org.springframework.util.ClassUtils;
public class PrintController {
    
    
	public void monitoringPrint() {
    
    
		//获取项目classes/static的地址
    	String staticPath = ClassUtils.getDefaultClassLoader().getResource("static").getPath();
		File file=new File(staticPath+"/invoice.pdf");
	}
}

Guess you like

Origin blog.csdn.net/qq_41936224/article/details/108726570