java - 在 tomcat 上运行简单的 hello restapi 时出现 404 响应

标签 java apache tomcat server port-number

我正在尝试遵循此 link 的基本 hello restAPI .该程序是在eclipse中用java完成的。

但是我得到了错误:

Several ports (8005, 8080, 8009) required by Tomcat v8.5 Server at localhost are 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 or change the port number(s).

我试过更改端口号,但没用。

我已经进行了检查,我在 8080 上获得了 apache 主页,而不是在更改后的端口号 8081 上。在 8081 上运行给我一个 404 响应,而在 8080 上运行会抛出上面显示的错误。

如何解决这种行为?

感谢任何帮助。

最佳答案

获取正在使用端口(8005、8080、8009)的进程的 PID,并在需要时从任务管理器中结束进程。

要获取PID,按照这个answer

Just open a command shell and type : (saying your port is 123456)

netstat -a -n -o | find "123456"

You will see everything you need

The headers are :

Proto  Local Address          Foreign Address        State          PID  
TCP    0.0.0.0:37             0.0.0.0:0              LISTENING      1111

关于java - 在 tomcat 上运行简单的 hello restapi 时出现 404 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51964378/

相关文章:

java - "The type Java.util.Map$Entry cannot be resolved"

tomcat - 如何在 tomcat 上托管我的 hiccup clojure 项目?

java - 如何使用 Java 将视频文件从 amazon s3 下载到特定文件夹

java - 我正在尝试让这个 run.bat 在 Linux CentOS 上运行

java - 在spring boot中连接到多个数据库

localhost - 无法让本地主机同时显示 WampServer 索引和动态 url

eclipse - 构建路径 eclipse java j2ee

java - Perl Web 服务的 JAX-WS 客户端

php - 不能在输出缓冲显示处理程序中使用输出缓冲

php - 选项指令禁止的目录索引