springboot打包启动访问不到jar外同级下static里的index.html

提问 6 1140
Don
Don 2020-10-13
版本:renren-fast 开发环境:
springboot 项目打包,使用本身web服务,省去nginx,防止前端项目更新需要频繁打包新jar,将static文件放到jar同级,目录结构如下:img[//cdn.renren.io/568d2202010131142315124.jpg] 启动项目访问ip:port 出现 img[//cdn.renren.io/a9b81202010131138424930.jpg] 路径改为 ip:port/static/index.html 能正常请求到界面, 现在要求是默认直接ip:port请求,如果jar包内部打包有static/index.html,直接请求是能正常响应,在配置文件设置了 spring-resources-static-locations: file:/opt/web/static/ 日志里是有 Adding welcome page URL [file:/opt/web/static/index.html] 但是没有任何作用
回帖
  • Don
    Don (楼主)
    2020-10-13
    static下面什么文件 以及静态资源都能请求到 就是访问不到index.html 改个名字也能访问到
    0 回复
  • Don
    Don (楼主)
    2020-10-13
    @Mark 麻烦解惑一下 谢谢
    0 回复
  • @Don 需要在ShiroConfig里面放行
    0 回复
  • Don
    Don (楼主)
    2020-10-13
    @Mark shiroconfig里面没有放行 不应该是 whitelabel error page 这种错误啊 应该是 please login的友情提示,如果我把static index.html都打到jar里面就能正常访问到 放到外面就找不到index 其他都能找到
    0 回复
  • @Don 是要放到jar里面
    0 回复
  • Don
    Don (楼主)
    2020-10-14
    @Mark index.html打包到jar就没有意义了 每次前端项目更新都得重新打包新jar,而且现在问题是static下面的所有文件都能请求到(包括别的html) 只要不叫index.html,所以一直卡在这了
    0 回复