ssm如何支持热部署_SSM项目频繁打成war包部署,使用tomcat和maven实现热部署配置

背景

众所周知,我们平时将JavaEE项目开发完后,需要将项目部署到服务器的tomcat上。常用的部署方式是将项目打包成war包放到tomcat的webapps下,然后重启tomcat,然后通过ip地址+端口号访问。这样部署本身是没问题的,但问题在于,如果还是在生产环境下的话,需要频繁的更改优化项目,那么就需要频繁的将项目打war包,替换webapps下的war包,操作繁琐。

接下来我们讲述如何实现本地编程,然后部署项目到远程服务器的tomcat上,实现热部署。

所用技术&工具

maven(项目构建和依赖管理)

tomcat7插件 (部署到tomcat的插件)

tomcat服务器 (web服务器)

编译器推荐使用IDEA

1.确保本地具有远程tomcat的使用权限

修改Tomcat下{TOMCAT_HOME}conf/tomcat-users.xml配置文件,添加用户名、密码、权限。

2.配置Tomcat允许远程访问

在远程服务器的{TOMCAT_HOME}conf/Catalina/localhost/目录下创建一个manager.xml文件,配置如下内容:

注:如果只想部分用户使用,可在allow配置IP,例如

allow="192.168.0.102"

3.重启远程Tomcat

在tomcat的bin目录下依次执行

//关闭tomcat

./shutdown.sh

//启动tomcat

./startup.sh

4.测试是否具有使用权限

访问tomcat,例如http://192.168.0.102:8080(使用自己的服务器或是虚拟机的ip地址)

点击Manager APP

f61d7895842d3e1422361bb475f77b84.png

输入刚才配置的tomcat的账号和密码

ec39c60de9225f939b3a3b2c03b7ee9d.png

如果跳转到这个页面证明配置完成

3feb2cf76dc37011461c14f64b8eb38e.png

当然也可以在当前页面实现war的部署和替换,这也是另一种部署方式,不过依然没有热部署方便

问题:如果出现403报错如下

403 Access Denied

You are not authorized to view this page.

By default the Manager is only accessible from a browser running on the same machine as Tomcat. If you wish to modify this restriction, you'll need to edit the Manager's context.xml file.

If you have already configured the Manager application to allow access and you have used your browsers back button, used a saved book-mark or similar then you may have triggered the cross-site request forgery (CSRF) protection that has been enabled for the HTML interface of the Manager application. You will need to reset this protection by returning to the main Manager page. Once you return to this page, you will be able to continue using the Manager application's HTML interface normally. If you continue to see this access denied message, check that you have the necessary permissions to access this application.

If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值