(JavaWeb eclipse报错解决)Resource '/Servers' does not exist.

关键词

eclipse JavaWeb ApplicationContext

背景描述

1.在服务器上运行TestHelloServlet.java时报错。该文件主要是通过Web服务器实例化ApplicationContext容器。

2.案例代码来自书籍《JavaEE框架整合开发入门到实战——Spring+SpringMVC+MyBatis》P14(2.2.2 ApplicationContext)

主要报错

1.Resource '/Servers' does not exist.

2.'Starting Tomcat v9.0 Server at localhost' has encountered a problem.
Port 8080 required byTomcat v9.0 Server at localhost is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the portnumber(s).

解决思路简述

1.删除原有Server,新建Server
2.修改端口
3.重启eclipse

过程描述(含解决方法)

1.在服务器上运行TestHelloServle As--Run on Server)

(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第1张图片

(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第2张图片
 
 
2.报错:

Resource '/Servers' does not exist.
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第3张图片

 
 
3.删除Server
1)删除底部Server面板的所有服务器;
2)删除左边Server文件夹
如果项目较为重要,建议备份一下Server文件夹。我的项目只是一些案例的学习,不太重要,所以直接删除
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第4张图片
 
 
4.新建Server(在对应项目上右击,比如Ch1项目,然后依次选择New--Other)
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第5张图片
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第6张图片
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第7张图片
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第8张图片
 
 

5.启动底部Server面板的服务器
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第9张图片
 
 
6.报错

'Starting Tomcat v9.0 Server at localhost' has encountered a problem.
Port 8080 required byTomcat v9.0 Server at localhost is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the portnumber(s).

 
可以看出原因是端口号8080被占用。解决方法有两个:①终止其他使用了端口8080的进程;②修改Tomcat的端口。

经分析,发现是电脑上的Apache Httpd使用了端口号8080(安装目的主要是为PHP所用,在Appserv下)。我决定直接修改Tomcat端口
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第10张图片
 
 
7.打开左侧Servers文件夹所在目录,用文本编辑器打开其下的server.xml文件,搜索相关文本,以修改端口。其中搜索内容为:

(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第11张图片
 
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第12张图片
 
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第13张图片
 
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第14张图片
 
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第15张图片
 
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第16张图片
 
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第17张图片
 
 

8.(务必)重启eclipse

9.启动Servers面板的服务器
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第18张图片
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第19张图片
 
 
10.在服务器上运行TestHelloServlet.java。(Run As--Run on Server)
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第20张图片
 
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第21张图片
 
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第22张图片
 
 
11.完成。
(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第23张图片

(JavaWeb eclipse报错解决)Resource '/Servers' does not exist._第24张图片

参考文章

eclipse中启动Tomcat,8080端口被占用

Resource '/servers' does not exist 问题的解决(转)

你可能感兴趣的:((JavaWeb eclipse报错解决)Resource '/Servers' does not exist.)