首先打包 npm run build:prod
打包好到dist文件夹 复制静态文件
在springboot 项目中的资源文件夹中创建templates 文件夹
前端静态文件放入
在配置文件中放行templates 文件夹的访问
resources:
static-locations: classpath:/templates
(在WebMvcConfigurer配置行:registry.addResourceHandler(“/**”).addResourceLocations(“classpath:/templates/”);)
注意 :如果配置完还是404 考虑 3种情况
1.public class InterceptorConfig implements WebMvcConfigurer 加上extends WebMvcAutoConfiguration
2.静态资源没加载到target
3.vue资源是是否添加了路径