tomcat 8.5.16踩坑篇

来源:互联网 发布:qq三国活力涨不停算法 编辑:程序博客网 时间:2024/05/22 03:36

tomcat下载地址:http://tomcat.apache.org
这里写图片描述
tomcat 7.0版本也尝试下载了一次进行安装,可惜的是需要获取系统权限设置:chmod 777 *.sh
亲测8.5.16不需要设置,
tomcat启动:./startup.sh
tomcat关闭:./shutdown.sh

但在进行角色设置时踩了坑,请看这里,
这里写图片描述
如果你不修改上图中箭头所示标识用户内容,则会报错

401 unauthoried

正确姿势是在./conf/tomcat-users.xml文件中的下方添加角色分配内容,没有添加之前显示内容为:

<?xml version="1.0" encoding="UTF-8"?><!--  Licensed to the Apache Software Foundation (ASF) under one or more  contributor license agreements.  See the NOTICE file distributed with  this work for additional information regarding copyright ownership.  The ASF licenses this file to You under the Apache License, Version 2.0  (the "License"); you may not use this file except in compliance with  the License.  You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software  distributed under the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the specific language governing permissions and  limitations under the License.--><tomcat-users xmlns="http://tomcat.apache.org/xml"              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"              version="1.0"><!--  NOTE:  By default, no user is included in the "manager-gui" role required  to operate the "/manager/html" web application.  If you wish to use this app,  you must define such a user - the username and password are arbitrary. It is  strongly recommended that you do NOT use one of the users in the commented out  section below since they are intended for use with the examples web  application.--><!--  NOTE:  The sample user and role entries below are intended for use with the  examples web application. They are wrapped in a comment and thus are ignored  when reading this file. If you wish to configure these users for use with the  examples web application, do not forget to remove the <!.. ..> that surrounds  them. You will also need to set the passwords to something appropriate.--><!--  <role rolename="tomcat"/>  <role rolename="role1"/>  <user username="tomcat" password="<must-be-changed>" roles="tomcat"/>  <user username="both" password="<must-be-changed>" roles="tomcat,role1"/>  <user username="role1" password="<must-be-changed>" roles="role1"/>--></tomcat-users>

修改后的内容为:

<?xml version="1.0" encoding="UTF-8"?><!--  Licensed to the Apache Software Foundation (ASF) under one or more  contributor license agreements.  See the NOTICE file distributed with  this work for additional information regarding copyright ownership.  The ASF licenses this file to You under the Apache License, Version 2.0  (the "License"); you may not use this file except in compliance with  the License.  You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software  distributed under the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the specific language governing permissions and  limitations under the License.--><tomcat-users xmlns="http://tomcat.apache.org/xml"              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"              version="1.0"><!--  NOTE:  By default, no user is included in the "manager-gui" role required  to operate the "/manager/html" web application.  If you wish to use this app,  you must define such a user - the username and password are arbitrary. It is  strongly recommended that you do NOT use one of the users in the commented out  section below since they are intended for use with the examples web  application.--><!--  NOTE:  The sample user and role entries below are intended for use with the  examples web application. They are wrapped in a comment and thus are ignored  when reading this file. If you wish to configure these users for use with the  examples web application, do not forget to remove the <!.. ..> that surrounds  them. You will also need to set the passwords to something appropriate.--><!--  <role rolename="tomcat"/>  <role rolename="role1"/>  <user username="tomcat" password="<must-be-changed>" roles="tomcat"/>  <user username="both" password="<must-be-changed>" roles="tomcat,role1"/>  <user username="role1" password="<must-be-changed>" roles="role1"/>-->  <role rolename="manager-gui"/>  <role rolename="manager-script"/>  <role rolename="manager-jmx"/>  <role rolename="manager-status"/>  <role rolename="admin-gui"/>  <role rolename="admin-script"/>  <user username="admin" password="admin" roles="manager-gui, manager-script, manager-jmx, manager-status, admin-gui, admin-script"/></tomcat-users>

然后进行登录:http://localhost:8080(或者是电脑IP+8080)
登录之后显示内容为:
这里写图片描述

踩坑续:
项目运行报错:

javax.servlet.http.httpservlet 不存在

切记:检查tomcat是否正确配置,且其tomcat中lib库是否包含了servlet.jar包!!!

以上即是今天踩坑内容,后续会继续进行改善。欢迎指出。

原创粉丝点击