当前位置: 首页 > news >正文

3. springboot中集成部署vue3

1. vue3构建

     构建命令 npm run build, 构建的结果在disc目录:

2. springboot集成

   2.1 拷贝vue3构建结果到springboot resources/static目录

2.2 springboot pom依赖

添加thymeleaf依赖

        <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!--thymeleaf--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency>

2.3 application.yml新增thymeleaf配置

server:port: 8081spring:# 打成jar包必须添加如下配置才能找到页面thymeleaf:mode: HTMLcache: falseprefix: classpath:/static

2.4 新增后台页面controller

package com.spring.test.demo.controller;import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;/*** 页面跳转控制器*/
@Controller
public class PageController {//后台页面@RequestMapping("/{backPage}")public String backPage(@PathVariable String backPage) {return "/" + backPage;}
}

2.5 运行springboot并访问后台页面

    访问后台页面: http://localhost:8081/index

http://www.lryc.cn/news/310223.html

相关文章:

  • 问题
  • #WEB前端
  • c语言经典测试题9
  • 3d 舞蹈同步
  • win环境nginx实战配置详解
  • 数字化转型导师坚鹏:如何制定证券公司数字化转型年度培训规划
  • 新王炸:文生视频Sora模型发布,能否引爆AI芯片热潮
  • 代码随想录算法训练营|day48
  • 架构面试题汇总:并发和锁(三)
  • 蓝桥杯(3.2)
  • [数据集][目标检测]鸟类检测数据集VOC+YOLO格式11758张200类别
  • YOLOv9:使用可编程梯度信息学习您想学习的内容
  • uniapp:使用DCloud的uni-push推送消息通知(在线模式)java实现
  • 【简说八股】面试官:你知道什么是AOP么?
  • ASUS华硕天选5笔记本电脑FX607JV原装出厂Win11系统下载
  • Unity(第二十一部)动画的基础了解(感觉不了解其实也行)
  • 写时复制简介
  • 运行Python文件时出现‘utf-8’code can‘t decode byte 如何解决?(如图)
  • 行为树入门:BehaviorTree.CPP Groot2练习(叶子节点)(2)
  • leetcode-字符串中的单词数
  • 一些C语言题目
  • JVM相关问题
  • 32单片机基础:旋转编码器计次
  • 【C++】vector的使用和模拟实现(超级详解!!!!)
  • GO学习记录
  • 迭代器模式(Iterator Pattern)
  • KL divergence(KL 散度)详解
  • AzerothCore@FreeBSD安装记录
  • vue .env配置环境变量
  • ThreadLocal介绍