若依前后端部署到一起

引用:https://blog.csdn.net/qq_42341853/article/details/129127553
前端改造:

  • 配置打包前缀
    在这里插入图片描述
  • 修改router.js 编程hash模式:
    在这里插入图片描述
    前端打包:npm run build:prod

后端修改:

  • 添加thymeleaf包,和配置文件
spring:
  # 模板引擎
  thymeleaf:
    mode: HTML
    encoding: utf-8
    cache: false

  • 修改后端ResourcesConfig.java中的 addResourceHandlers,添加静态资源映射地址
/** 前端静态资源配置 */
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");

  • 修改后端SecurityConfig.java中的 configure,添加允许访问的地址。
//静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**","/static/**","/index","/*.ico").permitAll()

  • 将静态资源放入static ,将html放入template
    在这里插入图片描述

  • 配置请求前缀 server.servlet.content-path
    在这里插入图片描述

  • 指定首页映射到index
    在这里插入图片描述

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-20 16:48:07       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-20 16:48:07       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-20 16:48:07       87 阅读
  4. Python语言-面向对象

    2024-04-20 16:48:07       96 阅读

热门阅读

  1. pytorch实现自己的深度神经网络(公共数据集)

    2024-04-20 16:48:07       32 阅读
  2. 户外景区亲子儿童剧本杀小程序小程序开发搭建

    2024-04-20 16:48:07       38 阅读
  3. Storm入门教程

    2024-04-20 16:48:07       34 阅读
  4. python项目练习——28.自动抢火车票脚本

    2024-04-20 16:48:07       31 阅读
  5. 使用QT与Web混合编程

    2024-04-20 16:48:07       33 阅读
  6. webrtc c++ native 获取local sdp流程

    2024-04-20 16:48:07       31 阅读
  7. vue:write-excel-file页面文字转为xlsx文件

    2024-04-20 16:48:07       35 阅读
  8. Cesium之home键开关及相机位置设置

    2024-04-20 16:48:07       33 阅读
  9. PostCSS概述

    2024-04-20 16:48:07       32 阅读