springboot配置集成vue前端並打包發佈
操作步驟
-
新建一個springboot工程orchid
-
新建一個vue項目併成功打包,可以參考https://www.cnblogs.com/ants_double/p/13391211.html
-
添加必要的依賴
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
-
添加controller入口
@Controller() @RequestMapping("/") public class IndexController { @GetMapping("home") public ModelAndView index(){ ModelAndView mv = new ModelAndView("index"); return mv; } }
-
配置資源文件
spring: thymeleaf: prefix: classpath:/templates/ suffix: .html servlet: content-type: text/html mode: HTML cache: false encoding: utf-8
-
放入vue生成的包文件(使用默認路徑)
- static 文件夾放入 resources/static文件夾下
- index.html放入resources/templates文件夾下
-
打包發佈
mvn package nohup java -jar ****.jar