一、配置vue打包参数

假如springboot的context-path为/ ,即根门路,那么我须要为动态资源分配一个路由,这里以pages为例,前端vue.config.js配置如下:

  publicPath: '/pages/',  outputDir: 'dist',  assetsDir: 'static',

二、springboot系列配置与解决

  1. 将context-path配置为根门路/,并设置shiro等权限框架对pages权限拦挡的疏忽,基于diboot低代码开发平台的我的项目配置如下:

    server.servlet.context-path=/diboot.iam.anon-urls=/pages/**
  2. 将前端打包好的dist中的文件夹和文件都放到 springboot我的项目的 resource/static/pages 目录下,如下:
  3. 拜访 localhsot:8080/pages/index.html 即可胜利

三、拜访门路优化:

上述计划每次必须拜访pages的路由才能够拜访到,那么咱们是否能够重定向到这里呢,是能够的。

  1. 增加以下controller代码,可从根门路主动重定向到上述门路:

    @RestControllerpublic class RootRedirectController { @GetMapping("/") public void redirect(HttpServletResponse response) throws Exception {     response.sendRedirect("/pages/index.html"); }}
  2. 增加权限框架对根门路疏忽权限查看,基于diboot低代码开发平台的我的项目配置如下:

    diboot.iam.anon-urls=/,/pages/**

diboot 简略高效的低代码开发框架