默认配置

spring:
  profiles:
    active: druid,mybatis,security,redis
  mvc:
    static-path-pattern: /**
  resources:
    static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/

获取本地资源,在默认配置后加上你所要获取的资源的路径。

假使我要获取的图片路径为D://upload/img/1.jpg,那么在默认路径后添加file:D://upload/img/,然后运行项目,这时访问该图片的路径为localhost:8080/1.jpg,如果添加的路径为:file:D://upload/,那么该图片访问路径为localhost:8080/img/1.jpg。

spring:
  profiles:
    active: druid,mybatis,security,redis
  mvc:
    static-path-pattern: /**
  resources:
    static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file: D://xxx/
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐