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";
    }
}    

猜你喜欢

转载自www.cnblogs.com/jvStarBlog/p/12712180.html