enter image description here我已经创建了一个 Java 企业 Web 应用程序并使用了 tomcat 服务器,但是当我尝试运行一个 jsp 文件时,它显示:运行“Tomcat 9.0.16 (Ubuntu)”时出错:端口超出范围:-1。 port : 8080 是免费的,谁能告诉我解决办法。
我检查了端口,没问题,换了端口,重启也没用!
最佳答案
对不起,如果为时已晚,但为了将来引用,我找到了解决方案。
在 Tomcat 安装文件夹中有一个文件 config/server.xml
。其中有一个标签Server
,属性为port
。默认设置为 -1,禁用关闭端口。
来自Apache Tomcat 9 Configuration Reference :
The TCP/IP port number on which this server waits for a shutdown command. Set to -1 to disable the shutdown port.
Note: Disabling the shutdown port works well when Tomcat is started using Apache Commons Daemon (running as a service on Windows or with jsvc on un*xes). It cannot be used when running Tomcat with the standard shell scripts though, as it will prevent shutdown.bat|.sh and catalina.bat|.sh from stopping it gracefully.
我猜 IntelliJ 使用这个端口来停止 Tomcat 服务器,因此如果没有设置它就会提示。也许 Jetbrains 考虑给出更多这方面的信息,让用户自己找到问题。
关于java - 在 Intellij Idea 上运行 tomcat 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57021825/