说明:打包使用的方式是把vue打包成dist文件后,放到若依的“ruoyi_admin”的静态文件模块下面,访问“http://localhost:9070/(端口“9070”是我自定义的)”即可!
步骤:
1、先打包vue后台管理系统
在若依项目的目录cmd输入命令:npm run build:prod
2、拿到打包后的dist文件,放到“ruoyi_admin”模块的“resources”下面新建“static”和“templates”
3、文件配置完后,配置跳转路径
上面的代码:
.antMatchers("/static/**").permitAll()//static
.antMatchers("/index/**").permitAll()//static
上面的代码块:
package com.ruoyi.web.controller.system;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.ruoyi.common.config.RuoYiConfig;/*** 首页** @author ruoyi*/
//@RestController
@Controller
public class SysIndexController
{/** 系统基础配置 */@Autowiredprivate RuoYiConfig ruoyiConfig;/*** 访问首页,提示语*/@RequestMapping(value = "/",method = RequestMethod.GET)public String index(){//return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());return "index";}/*** 访问首页,提示语*/@RequestMapping(value = "/index",method = RequestMethod.GET)public String indexs(){return "index";}
}
yml配置:
spring:mvc:view:suffix: .htmlstatic-path-pattern: /**resources:static-locations: classpath:/templates/,classpath:/static/
“ruoyi_admin”模块的“pom.xml”
<!--静态页面html--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId><version>2.1.6.RELEASE</version></dependency><!--静态页面html-->