tomcat部署war包不成功解决方法

2022-09-02 10:36:27 浏览数 (1)

大家好,又见面了,我是你们的朋友全栈君。

今天尝试在阿里云服务器中的tomcat部署项目

点击manager App 时页面显示这样,根据上图提示可知原因是cont/tomcat-users.xml 未配置用户名和密码, 所以需要将下面这段配置用户名和密码的代码添加到tomcat-users.xml中

代码语言:javascript复制
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>

保存后重启tomcat,再点击manage app 后提示输入 账号:tomcat 密码:tomcat 即可打开网址

若出现了403问题,则是因为访问受限了

代码语言:javascript复制
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.
 
For example, to add the manager-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above

这时候需要修改 /webapps/manager/META_INF/context.xml文件,将文件中对访问的来源受限设置注释:

代码语言:javascript复制
<Context antiResourceLocking="false" privileged="true" >
  <!--注释这里,去除对访问权限的设置
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127.d .d .d |::1|0:0:0:0:0:0:0:1" />
         -->
</Context>

修改后再重新点击Manage App 即可打开管理界面

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/138888.html原文链接:https://javaforall.cn

0 人点赞