1. 程式人生 > >spring boot在配置檔案中設定虛擬路徑

spring boot在配置檔案中設定虛擬路徑

由於spring Boot是內建tomcat的,所以無法用之前的設定虛擬路徑的方式進行設定,spring Boot提供了方便的配置方案,只需要在配置檔案中配置就可以.
具體程式碼:

 web.img-path=E:/zhangzd/petfishphotos/     //自定義屬性,以/結尾

spring.mvc.static-path-pattern=/**   //所有的訪問都經過靜態資源路徑;
spring.resources.static-locations=   //配置靜態資源路徑
  classpath:/META-INF/resources/,classpath:/resources/,\
  classpath:/static
/,classpath:/public/,file:${web.img-path}