How to configure embedded Tomcat integrated with Spring to listen requests to IP address, besides localhost?

后端 未结 4 813
长情又很酷
长情又很酷 2020-11-27 15:57

I am trying to run the example from the spring guide : Building a RESTful Web Service .

It works well if I open localhost:8080/greeting.

But it cann

4条回答
  •  孤城傲影
    2020-11-27 16:09

    In order to specify a which IP you want Tomcat to bind too, I believe you can simply add the following to your application.properties:

    server.address=
    server.port=
    

    Replacing with the IP address you want it to listen on. This, and other basic properties, can be found in the Spring Boot Reference Guide, Appendix A.

    The other way to configure the embedded Tomcat is to create a custom configurer in code by implementing the EmbeddedServletContainerCustomizer interface. You can read more about this in the Spring Boot Reference Guide, Section 55.5-55.8.

提交回复
热议问题