SpringBoot--实用配置汇总

静态资源目录配置(前段打好的包可以放在该目录下,从而实现前后端整合)

#application.yml配置文件新增如下配置
spring:
  mvc:
    static-path-pattern: /**
  resources:
    static-locations: classpath:/static,file:/root/webproject/dist  #windows系统下绝对路径:file:E:/static/
@Controller
public class DefaultController {
    @RequestMapping(value ="/",method = RequestMethod.GET)
    public String home() {
        //会到配置的静态资源目录搜索下面文件返回
        return "/index.html";
    }
}    

 项目结构:

 

posted @ 2020-04-16 13:17  11014p  阅读(166)  评论(0编辑  收藏  举报