SpringMvc+Tomcat+Angular4 部署运行

这次的团队开发是,前端开发人员和后台开发人员完全分开开发的。

前端开发采用了Angular4,webstorm

后端开发采用了:spring+springmvc+mybatis,eclipse

---------------------------------------

最后要整合了。


1、angular项目编译

SpringMvc+Tomcat+Angular4 部署运行


会生成 dist 文件夹。


2、拷贝dist文件夹到eclipse项目文件里

SpringMvc+Tomcat+Angular4 部署运行



3、修改dist/index.html的<base href="">

改为项目名+文件名

/doapplication/dist/

<base href="/doapplication/dist/">


4、springmvc文件里增加<mvc:resources 节点配置

<mvc:resources location="/dist/" mapping="/dist/**" />


5、运行,访问

http://localhost:8080/doapplication/dist/index.html



----------2018-01-04---补充


现在我们更简单的方法是:
angular编译后的  dist 文件夹,

修改dist/index.html的<base href="">

改为项目名+文件名

/doapplication/dist/

<base href="/doapplication/dist/">


放到同一个tomcat的webapp下,后台代码不用做任何修改和配置,启动tomcat直接可以访问。

访问路径:/项目名/dist/index.html