@SpringBootApplicationpublicclassDemoApplication{publicstaticvoidmain(String[]args){SpringApplication.run(DemoApplication.class,args);ApplicationHomehome=newApplicationHome(DemoApplication.class);home.getDir();// returns the folder where the jar is. This is what I wanted.
home.getSource();// returns the jar absolute path.
//输出如下:
//C:\Users\foo\IdeaProjects\code-snippet\spring-boot\demo\target
//C:\Users\foo\IdeaProjects\code-snippet\spring-boot\demo\target\demo-0.0.1-SNAPSHOT.jar
}}