目录
一、新建一个SpringBoot项目
(博主SpringBoot版本2.7.14)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
二、将Vue项目打包
(博主vue版本:3.2.44)
由于是要放在SpringBoot中,Java服务和Web服务用的是同一个端口,所以我们给前端一个统一的URL前缀来区分前端页面和后端接口。比如:/admin;配置方式如下:在src/router文件夹下找到路由文件,注意要用history模式,不要用哈希。
至于打包,就跟平时打包到nginx一样的去打包就行了。(不要添加base参数,画蛇添足!)
三、打包文件放到SpringBoot中
在SpringBoot的resources中新建static文件夹,然后将打包后的文件复制进来