由于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}