Java 如何更改tomcat端口号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18415578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 01:25:53  来源:igfitidea点击:

How to change tomcat port number

javatomcatport

提问by Siva Siva

I am developing a web application in JSP, in that for some purpose I need to change tomcat accessing port.

我正在用 JSP 开发一个 Web 应用程序,出于某种目的,我需要更改 tomcat 访问端口。

Is there any possibility?

有没有可能?

采纳答案by kark

Simple !!... you can do it easily via server.xml

简单!!...您可以通过 server.xml 轻松完成

  • Go to tomcat>conffolder
  • Edit server.xml
  • Search "Connector port"
  • Replace "8080" by your port number
  • Restart tomcat server.
  • 转到tomcat>conf文件夹
  • 编辑 server.xml
  • 搜索“连接器端口”
  • 将“8080”替换为 your port number
  • 重启tomcat服务器。

You are done!.

你完成了!

回答by Juned Ahsan

You need to edit the Tomcat/conf/server.xmland change the connector port. The connector setting should look something like this:

您需要编辑Tomcat/conf/server.xml和更改连接器端口。连接器设置应如下所示:

<Connector port="8080" maxHttpHeaderSize="8192"
           maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
           enableLookups="false" redirectPort="8443" acceptCount="100"
           connectionTimeout="20000" disableUploadTimeout="true" />

Just change the connector port from default 8080 to another valid port number.

只需将连接器端口从默认 8080 更改为另一个有效端口号。

回答by Prabhakaran Ramaswamy

Navigate to /tomcat-root/conf folder. Within you will find the server.xml file.

导航到 /tomcat-root/conf 文件夹。您将在其中找到 server.xml 文件。

Open the server.xml in your preferred editor. Search the below similar statement (not exactly same as below will differ)

在首选编辑器中打开 server.xml。搜索下面的类似语句(与下面不完全相同会有所不同)

    <Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" />

Going to give the port number to 9090

将端口号设置为 9090

     <Connector port="9090" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" />

Save the file and restart the server. Now the tomcat will listen at port 9090

保存文件并重新启动服务器。现在 tomcat 将监听 9090 端口

回答by Deepika C P

1) Locate server.xml in {Tomcat installation folder}\ conf \ 2) Find following similar statement

1) 在 {Tomcat 安装文件夹}\ conf \ 中找到 server.xml 2) 找到以下类似的语句

       <!-- Define a non-SSL HTTP/1.1 Connector on port 8180 -->
      <Connector port="8080" maxHttpHeaderSize="8192"
           maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
           enableLookups="false" redirectPort="8443" acceptCount="100"
           connectionTimeout="20000" disableUploadTimeout="true" />

For example

例如

<Connector port="8181" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" />

Edit and save the server.xml file. Restart Tomcat. Done

编辑并保存 server.xml 文件。重启Tomcat。完毕

Further reference: http://www.mkyong.com/tomcat/how-to-change-tomcat-default-port/

进一步参考:http: //www.mkyong.com/tomcat/how-to-change-tomcat-default-port/