(JavaWeb eclipse報錯解決)Resource '/Servers' does not exist.

關鍵詞

eclipse JavaWeb ApplicationContextjava

背景描述

1.在服務器上運行TestHelloServlet.java時報錯。該文件主要是經過Web服務器實例化ApplicationContext容器。服務器

2.案例代碼來自書籍《JavaEE框架整合開發入門到實戰——Spring+SpringMVC+MyBatis》P14(2.2.2 ApplicationContext)框架

主要報錯

1.Resource '/Servers' does not exist.eclipse

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)ui

image.png

image.png
 
 
2.報錯:this

Resource '/Servers' does not exist.
image.png

 
 
3.刪除Server
1)刪除底部Server面板的全部服務器;
2)刪除左邊Server文件夾
若是項目較爲重要,建議備份一下Server文件夾。個人項目只是一些案例的學習,不過重要,因此直接刪除
image.png
 
 
4.新建Server(在對應項目上右擊,好比Ch1項目,而後依次選擇New--Other)
image.png
image.png
image.png
image.png
 
 spa

5.啓動底部Server面板的服務器
image.png
 
 
6.報錯.net

'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端口
image.png
 
 
7.打開左側Servers文件夾所在目錄,用文本編輯器打開其下的server.xml文件,搜索相關文本,以修改端口。其中搜索內容爲:

<Connector connectionTimeout=

image.png
 
image.png
 
image.png
 
image.png
 
image.png
 
image.png
 
image.png
 
 

8.(務必)重啓eclipse

9.啓動Servers面板的服務器
image.png
image.png
 
 
10.在服務器上運行TestHelloServlet.java。(Run As--Run on Server)
image.png
 
image.png
 
image.png
 
 
11.完成。
image.png

image.png

參考文章

eclipse中啓動Tomcat,8080端口被佔用

Resource '/servers' does not exist 問題的解決(轉)

相關文章
相關標籤/搜索