vue项目如何部署到Tomcat中

1,假设你要访问的项目名称为‘hms’html

2,在Tomcat的webapps下建立hms文件夹,web

3,配置config/index.js文件,设置assetsPublicPath: '/hms/'npm

    (解释:这里改成这个配置以后,最后编译产生的index.html中相关路径也会带上‘/hms’,不会报404的错误了)app

4,在项目运行“npm run build:prod”命令,生成dist文件夹,dist文件夹中包含static和index.htmlwebapp

5,将dist文件夹中static和index.html复制到Tomcat中webapps的hms文件夹中ui

6,启动Tomcat,ip:port/hms,例如:http://localhost:8081/hms/便可访问到Vue项目。htm

相关文章
相关标签/搜索