关键词

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)


 
 
2.报错:

Resource '/Servers' does not exist.

 
 
3.删除Server
1)删除底部Server面板的所有服务器;
2)删除右边Server文件夹
如果我的项目较为重要,倡议备份一下Server文件夹。我的我的项目只是一些案例的学习,不太重要,所以间接删除

 
 
4.新建Server(在对应我的项目上右击,比方Ch1我的项目,而后顺次抉择New--Other)




 
 

5.启动底部Server面板的服务器

 
 
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端口

 
 
7.关上左侧Servers文件夹所在目录,用文本编辑器关上其下的server.xml文件,搜寻相干文本,以批改端口。其中搜寻内容为:

<Connector connectionTimeout=


 

 

 

 

 

 

 
 

8.(务必)重启eclipse

9.启动Servers面板的服务器


 
 
10.在服务器上运行TestHelloServlet.java。(Run As--Run on Server)

 

 

 
 
11.实现。

参考文章

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

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